annotate graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java @ 14865:ae7cbf13e765

correct guarding of Debug.logv in InliningUtil
author Erik Eckstein <erik.eckstein@oracle.com>
date Fri, 28 Mar 2014 08:26:21 +0100
parents fbae9be45c95
children 89a079df9cb4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
4233
fa53d5e4aa35 Remove lock information from frame states, and compute it instead when LIR is generated.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4205
diff changeset
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
6526
ee651c726397 split phases out of graal.phases project into graal.phases.common project
Doug Simon <doug.simon@oracle.com>
parents: 6525
diff changeset
23 package com.oracle.graal.phases.common;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
11839
0e2cceed1caf Temporarily move encodeDeoptActionAndReason to MetaAccessProvider
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11712
diff changeset
25 import static com.oracle.graal.api.meta.DeoptimizationAction.*;
10637
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
26 import static com.oracle.graal.api.meta.DeoptimizationReason.*;
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
27 import static com.oracle.graal.nodes.type.StampFactory.*;
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9837
diff changeset
28 import static com.oracle.graal.phases.GraalOptions.*;
13118
d511d688b782 re-enabled TieredCompilation when GRAAL is defined by handling abstract types in profiles gathered by C1
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
29 import static java.lang.reflect.Modifier.*;
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9837
diff changeset
30
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
31 import java.lang.reflect.*;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
32 import java.util.*;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
33
5510
426c605c9d3c Move cri.ci to api.code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5507
diff changeset
34 import com.oracle.graal.api.code.*;
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
35 import com.oracle.graal.api.code.Assumptions.Assumption;
5507
dc71b06d09f8 Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5506
diff changeset
36 import com.oracle.graal.api.meta.*;
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
37 import com.oracle.graal.api.meta.JavaTypeProfile.ProfiledType;
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6526
diff changeset
38 import com.oracle.graal.api.meta.ResolvedJavaType.Representation;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
39 import com.oracle.graal.debug.*;
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13196
diff changeset
40 import com.oracle.graal.debug.Debug.Scope;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
41 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
42 import com.oracle.graal.graph.Graph.DuplicationReplacement;
11573
8a3d99fc36cf Pass canonicalizer into tail duplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 11270
diff changeset
43 import com.oracle.graal.graph.Node.Verbosity;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
44 import com.oracle.graal.nodes.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
45 import com.oracle.graal.nodes.calc.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
46 import com.oracle.graal.nodes.extended.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
47 import com.oracle.graal.nodes.java.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
48 import com.oracle.graal.nodes.java.MethodCallTargetNode.InvokeKind;
8637
ce5750014c3d moved Replacements and MacroSubstitution from the graal.api.replacements project to graal.nodes project and reversed the dependency between these two projects (the latter now/again depends on the former)
Doug Simon <doug.simon@oracle.com>
parents: 8636
diff changeset
49 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
50 import com.oracle.graal.nodes.type.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
51 import com.oracle.graal.nodes.util.*;
6525
2c913b643422 rename packages in graal.phases to match project name
Doug Simon <doug.simon@oracle.com>
parents: 6522
diff changeset
52 import com.oracle.graal.phases.*;
9705
de7319e48e48 Temporary fixes for the merge.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9704
diff changeset
53 import com.oracle.graal.phases.common.InliningPhase.InliningData;
9329
fa188fbfe3fe Perform only targeted canonicalization after tail duplication.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9310
diff changeset
54 import com.oracle.graal.phases.tiers.*;
12054
bba234a1670e grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12052
diff changeset
55 import com.oracle.graal.phases.util.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
56
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
57 public class InliningUtil {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
58
5786
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
59 private static final DebugMetric metricInliningTailDuplication = Debug.metric("InliningTailDuplication");
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
60 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
61 /**
7660
0b646334c5f7 keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents: 7558
diff changeset
62 * Meters the size (in bytecodes) of all methods processed during compilation (i.e., top level
0b646334c5f7 keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents: 7558
diff changeset
63 * and all inlined methods), irrespective of how many bytecodes in each method are actually
0b646334c5f7 keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents: 7558
diff changeset
64 * parsed (which may be none for methods whose IR is retrieved from a cache).
7558
223f645acb9b added compilation rate measurements on top of existing metric/timer facility - enabled with -Dgraal.benchmark.compilation=true
Doug Simon <doug.simon@oracle.com>
parents: 7540
diff changeset
65 */
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
66 public static final DebugMetric InlinedBytecodes = Debug.metric("InlinedBytecodes");
223f645acb9b added compilation rate measurements on top of existing metric/timer facility - enabled with -Dgraal.benchmark.compilation=true
Doug Simon <doug.simon@oracle.com>
parents: 7540
diff changeset
67
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
68 public interface InliningPolicy {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
69
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
70 boolean continueInlining(StructuredGraph graph);
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
71
10933
9878214a0093 Remove fields from InliningPhase that are already available in HighTierContext.
Roland Schatz <roland.schatz@oracle.com>
parents: 10930
diff changeset
72 boolean isWorthInlining(Replacements replacements, InlineInfo info, int inliningDepth, double probability, double relevance, boolean fullyProcessed);
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
73 }
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
74
9921
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
75 public interface Inlineable {
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
76
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
77 int getNodeCount();
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
78
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
79 Iterable<Invoke> getInvokes();
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
80 }
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
81
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
82 public static class InlineableGraph implements Inlineable {
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
83
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
84 private final StructuredGraph graph;
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
85
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
86 public InlineableGraph(StructuredGraph graph) {
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
87 this.graph = graph;
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
88 }
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
89
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
90 @Override
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
91 public int getNodeCount() {
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
92 return graph.getNodeCount();
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
93 }
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
94
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
95 @Override
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
96 public Iterable<Invoke> getInvokes() {
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
97 return graph.getInvokes();
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
98 }
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
99
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
100 public StructuredGraph getGraph() {
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
101 return graph;
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
102 }
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
103 }
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
104
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
105 public static class InlineableMacroNode implements Inlineable {
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
106
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
107 private final Class<? extends FixedWithNextNode> macroNodeClass;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
108
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
109 public InlineableMacroNode(Class<? extends FixedWithNextNode> macroNodeClass) {
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
110 this.macroNodeClass = macroNodeClass;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
111 }
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
112
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
113 @Override
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
114 public int getNodeCount() {
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
115 return 1;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
116 }
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
117
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
118 @Override
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
119 public Iterable<Invoke> getInvokes() {
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
120 return Collections.emptyList();
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
121 }
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
122
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
123 public Class<? extends FixedWithNextNode> getMacroNodeClass() {
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
124 return macroNodeClass;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
125 }
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
126 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
127
8996
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
128 /**
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
129 * Print a HotSpot-style inlining message to the console.
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
130 */
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
131 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
132 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
133 }
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
134
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
135 /**
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
136 * Print a HotSpot-style inlining message to the console.
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
137 */
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
138 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
139 if (HotSpotPrintInlining.getValue()) {
8996
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
140 final int mod = method.getModifiers();
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
141 // 1234567
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
142 TTY.print(" "); // print timestamp
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
143 // 1234
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
144 TTY.print(" "); // print compilation number
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
145 // % s ! b n
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
146 TTY.print("%c%c%c%c%c ", ' ', Modifier.isSynchronized(mod) ? 's' : ' ', ' ', ' ', Modifier.isNative(mod) ? 'n' : ' ');
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
147 TTY.print(" "); // more indent
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
148 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
149 for (int i = 0; i < inliningDepth; i++) {
8996
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
150 TTY.print(" ");
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
151 }
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
152 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
153 }
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
154 }
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
155
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
156 public static boolean logInlinedMethod(InlineInfo info, int inliningDepth, boolean allowLogging, String msg, Object... args) {
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
157 return logInliningDecision(info, inliningDepth, allowLogging, true, msg, args);
8996
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
158 }
6d86ce1297bc GRAAL-213: add HotSpot-style PrintCompilation and PrintInlining
twisti
parents: 8649
diff changeset
159
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
160 public static boolean logNotInlinedMethod(InlineInfo info, int inliningDepth, String msg, Object... args) {
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
161 return logInliningDecision(info, inliningDepth, true, false, msg, args);
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
162 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
163
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
164 public static boolean 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
165 if (allowLogging) {
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
166 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
167 if (shouldLogInliningDecision()) {
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
168 logInliningDecision(methodName(info), success, msg, args);
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
169 }
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
170 }
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
171 return success;
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
172 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
173
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
174 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
175 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
176 // Can't use log here since we are varargs
14865
ae7cbf13e765 correct guarding of Debug.logv in InliningUtil
Erik Eckstein <erik.eckstein@oracle.com>
parents: 14850
diff changeset
177 if (Debug.isEnabled()) {
14719
0bdd0d157040 fix vargs -> Object -> vargs logging call paths
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14708
diff changeset
178 Debug.logv(msg, args);
0bdd0d157040 fix vargs -> Object -> vargs logging call paths
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14708
diff changeset
179 }
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
180 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
181 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
182
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
183 private static boolean logNotInlinedMethod(Invoke invoke, String msg) {
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
184 if (shouldLogInliningDecision()) {
7391
36dafe48bc38 added relevance-based inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7388
diff changeset
185 String methodString = invoke.toString() + (invoke.callTarget() == null ? " callTarget=null" : invoke.callTarget().targetName());
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
186 logInliningDecision(methodString, false, msg, new Object[0]);
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
187 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
188 return false;
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
189 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
190
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
191 private static InlineInfo logNotInlinedMethodAndReturnNull(Invoke invoke, int inliningDepth, ResolvedJavaMethod method, String msg) {
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
192 return logNotInlinedMethodAndReturnNull(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
193 }
ceb8c5b29419 print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7098
diff changeset
194
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
195 private static InlineInfo logNotInlinedMethodAndReturnNull(Invoke invoke, int inliningDepth, ResolvedJavaMethod method, String msg, Object... args) {
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
196 printInlining(method, invoke, inliningDepth, false, msg, args);
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
197 if (shouldLogInliningDecision()) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
198 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
199 logInliningDecision(methodString, false, msg, args);
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
200 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
201 return null;
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
202 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
203
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
204 private static boolean logNotInlinedMethodAndReturnFalse(Invoke invoke, int inliningDepth, ResolvedJavaMethod method, String msg) {
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
205 printInlining(method, invoke, inliningDepth, false, msg, new Object[0]);
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
206 if (shouldLogInliningDecision()) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
207 String methodString = methodName(method, invoke);
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
208 logInliningDecision(methodString, false, msg, new Object[0]);
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
209 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
210 return false;
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
211 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
212
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
213 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
214 String inliningMsg = "inlining " + methodString + ": " + msg;
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
215 if (!success) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
216 inliningMsg = "not " + inliningMsg;
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
217 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
218 logInliningDecision(inliningMsg, args);
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
219 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
220
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
221 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
222 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
223 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
224 }
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
225 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
226
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
227 private static String methodName(ResolvedJavaMethod method, Invoke invoke) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
228 if (invoke != null && invoke.stateAfter() != null) {
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6526
diff changeset
229 return methodName(invoke.stateAfter(), invoke.bci()) + ": " + MetaUtil.format("%H.%n(%p):%r", method) + " (" + method.getCodeSize() + " bytes)";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
230 } else {
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6526
diff changeset
231 return MetaUtil.format("%H.%n(%p):%r", method) + " (" + method.getCodeSize() + " bytes)";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
232 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
233 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
234
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
235 private static String methodName(InlineInfo info) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
236 if (info == null) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
237 return "null";
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
238 } else if (info.invoke() != null && info.invoke().stateAfter() != null) {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
239 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
240 } 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
241 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
242 }
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
243 }
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
244
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
245 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
246 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
247 if (frameState.outerFrameState() != null) {
8ac40aed34bf Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
248 sb.append(methodName(frameState.outerFrameState(), frameState.outerFrameState().bci));
8ac40aed34bf Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
249 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
250 }
5719
429accae15aa moved some methods from CodeUtil to MetaUtil
Doug Simon <doug.simon@oracle.com>
parents: 5718
diff changeset
251 sb.append(MetaUtil.format("%h.%n", frameState.method()));
5316
8ac40aed34bf Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5210
diff changeset
252 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
253 return sb.toString();
5127
7b2efb5ff2ea better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5114
diff changeset
254 }
7b2efb5ff2ea better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5114
diff changeset
255
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
256 /**
10637
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
257 * Represents an opportunity for inlining at a given invoke, with the given weight and level.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
258 * The weight is the amortized weight of the additional code - so smaller is better. The level
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
259 * is the number of nested inlinings that lead to this invoke.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
260 */
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
261 public interface InlineInfo {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
262
10637
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
263 /**
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
264 * The graph containing the {@link #invoke() invocation} that may be inlined.
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
265 */
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
266 StructuredGraph graph();
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
267
10637
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
268 /**
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
269 * The invocation that may be inlined.
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
270 */
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
271 Invoke invoke();
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
272
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
273 /**
10637
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
274 * Returns the number of methods that may be inlined by the {@link #invoke() invocation}.
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
275 * This may be more than one in the case of a invocation profile showing a number of "hot"
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
276 * concrete methods dispatched to by the invocation.
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
277 */
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
278 int numberOfMethods();
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
279
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
280 ResolvedJavaMethod methodAt(int index);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
281
9921
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
282 Inlineable inlineableElementAt(int index);
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
283
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
284 double probabilityAt(int index);
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
285
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
286 double relevanceAt(int index);
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
287
9921
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
288 void setInlinableElement(int index, Inlineable inlineableElement);
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
289
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
290 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
291 * Performs the inlining described by this object and returns the node that represents the
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
292 * return value of the inlined method (or null for void methods and methods that have no
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
293 * non-exceptional exit).
11959
23ccaa863eda made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11878
diff changeset
294 */
12054
bba234a1670e grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12052
diff changeset
295 void inline(Providers providers, Assumptions assumptions);
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
296
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
297 /**
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
298 * Try to make the call static bindable to avoid interface and virtual method calls.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
299 */
11959
23ccaa863eda made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11878
diff changeset
300 void tryToDevirtualizeInvoke(MetaAccessProvider metaAccess, Assumptions assumptions);
13953
d587baa55dd7 Add shouldBeInlined method to ResolvedJavaMethod, implement it for HotSpot and use it in the inlining phase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13692
diff changeset
301
d587baa55dd7 Add shouldBeInlined method to ResolvedJavaMethod, implement it for HotSpot and use it in the inlining phase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13692
diff changeset
302 boolean shouldInline();
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
303 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
304
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
305 public abstract static class AbstractInlineInfo implements InlineInfo {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
306
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
307 protected final Invoke invoke;
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
308
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
309 public AbstractInlineInfo(Invoke invoke) {
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
310 this.invoke = invoke;
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
311 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
312
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
313 @Override
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
314 public StructuredGraph graph() {
9705
de7319e48e48 Temporary fixes for the merge.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9704
diff changeset
315 return invoke.asNode().graph();
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
316 }
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
317
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
318 @Override
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
319 public Invoke invoke() {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
320 return invoke;
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
321 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
322
9921
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
323 protected static void inline(Invoke invoke, ResolvedJavaMethod concrete, Inlineable inlineable, Assumptions assumptions, boolean receiverNullCheck) {
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
324 if (inlineable instanceof InlineableGraph) {
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
325 StructuredGraph calleeGraph = ((InlineableGraph) inlineable).getGraph();
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
326 InliningUtil.inline(invoke, calleeGraph, receiverNullCheck);
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
327 } else {
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
328 assert inlineable instanceof InlineableMacroNode;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
329
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
330 Class<? extends FixedWithNextNode> macroNodeClass = ((InlineableMacroNode) inlineable).getMacroNodeClass();
13601
fd522e725ee5 inliningutils: minor refactor
Bernhard Urban <bernhard.urban@jku.at>
parents: 13554
diff changeset
331 inlineMacroNode(invoke, concrete, macroNodeClass);
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
332 }
7660
0b646334c5f7 keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents: 7558
diff changeset
333
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
334 InlinedBytecodes.add(concrete.getCodeSize());
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
335 assumptions.recordMethodContents(concrete);
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
336 }
9310
b0f9ab5a185b Devirtualize invoke before handing it to the macro node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9238
diff changeset
337 }
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
338
9310
b0f9ab5a185b Devirtualize invoke before handing it to the macro node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9238
diff changeset
339 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
340 MethodCallTargetNode oldCallTarget = (MethodCallTargetNode) invoke.callTarget();
b0f9ab5a185b Devirtualize invoke before handing it to the macro node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9238
diff changeset
341 MethodCallTargetNode newCallTarget = graph.add(new MethodCallTargetNode(invokeKind, targetMethod, oldCallTarget.arguments().toArray(new ValueNode[0]), oldCallTarget.returnType()));
b0f9ab5a185b Devirtualize invoke before handing it to the macro node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9238
diff changeset
342 invoke.asNode().replaceFirstInput(oldCallTarget, newCallTarget);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
343 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
344
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
345 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
346 * Represents an inlining opportunity where the compiler can statically determine a monomorphic
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
347 * target method and therefore is able to determine the called method exactly.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
348 */
11689
8d0303d8dbde make GreedyInliningPolicy/ExactInlineInfo public, allow optional null check suppression on inline
Mick Jordan <mick.jordan@oracle.com>
parents: 11675
diff changeset
349 public static class ExactInlineInfo extends AbstractInlineInfo {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
350
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
351 protected final ResolvedJavaMethod concrete;
9921
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
352 private Inlineable inlineableElement;
11689
8d0303d8dbde make GreedyInliningPolicy/ExactInlineInfo public, allow optional null check suppression on inline
Mick Jordan <mick.jordan@oracle.com>
parents: 11675
diff changeset
353 private boolean suppressNullCheck;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
354
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
355 public ExactInlineInfo(Invoke invoke, ResolvedJavaMethod concrete) {
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
356 super(invoke);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
357 this.concrete = concrete;
9961
a91b0d42917f Slightly simplified inlining policy.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9927
diff changeset
358 assert concrete != null;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
359 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
360
11689
8d0303d8dbde make GreedyInliningPolicy/ExactInlineInfo public, allow optional null check suppression on inline
Mick Jordan <mick.jordan@oracle.com>
parents: 11675
diff changeset
361 public void suppressNullCheck() {
8d0303d8dbde make GreedyInliningPolicy/ExactInlineInfo public, allow optional null check suppression on inline
Mick Jordan <mick.jordan@oracle.com>
parents: 11675
diff changeset
362 suppressNullCheck = true;
8d0303d8dbde make GreedyInliningPolicy/ExactInlineInfo public, allow optional null check suppression on inline
Mick Jordan <mick.jordan@oracle.com>
parents: 11675
diff changeset
363 }
8d0303d8dbde make GreedyInliningPolicy/ExactInlineInfo public, allow optional null check suppression on inline
Mick Jordan <mick.jordan@oracle.com>
parents: 11675
diff changeset
364
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
365 @Override
12054
bba234a1670e grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12052
diff changeset
366 public void inline(Providers providers, Assumptions assumptions) {
11689
8d0303d8dbde make GreedyInliningPolicy/ExactInlineInfo public, allow optional null check suppression on inline
Mick Jordan <mick.jordan@oracle.com>
parents: 11675
diff changeset
367 inline(invoke, concrete, inlineableElement, assumptions, !suppressNullCheck);
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 @Override
11959
23ccaa863eda made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11878
diff changeset
371 public void tryToDevirtualizeInvoke(MetaAccessProvider metaAccess, Assumptions assumptions) {
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
372 // nothing todo, can already be bound statically
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
373 }
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
374
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
375 @Override
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
376 public int numberOfMethods() {
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
377 return 1;
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
378 }
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
379
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
380 @Override
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
381 public ResolvedJavaMethod methodAt(int index) {
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
382 assert index == 0;
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
383 return concrete;
4528
e6e14d25e608 added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4473
diff changeset
384 }
e6e14d25e608 added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4473
diff changeset
385
e6e14d25e608 added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4473
diff changeset
386 @Override
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
387 public double probabilityAt(int index) {
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
388 assert index == 0;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
389 return 1.0;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
390 }
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
391
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
392 @Override
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
393 public double relevanceAt(int index) {
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
394 assert index == 0;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
395 return 1.0;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
396 }
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
397
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
398 @Override
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
399 public String toString() {
5719
429accae15aa moved some methods from CodeUtil to MetaUtil
Doug Simon <doug.simon@oracle.com>
parents: 5718
diff changeset
400 return "exact " + MetaUtil.format("%H.%n(%p):%r", concrete);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
401 }
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
402
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
403 @Override
9921
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
404 public Inlineable inlineableElementAt(int index) {
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
405 assert index == 0;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
406 return inlineableElement;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
407 }
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
408
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
409 @Override
9921
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
410 public void setInlinableElement(int index, Inlineable inlineableElement) {
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
411 assert index == 0;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
412 this.inlineableElement = inlineableElement;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
413 }
13953
d587baa55dd7 Add shouldBeInlined method to ResolvedJavaMethod, implement it for HotSpot and use it in the inlining phase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13692
diff changeset
414
d587baa55dd7 Add shouldBeInlined method to ResolvedJavaMethod, implement it for HotSpot and use it in the inlining phase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13692
diff changeset
415 public boolean shouldInline() {
d587baa55dd7 Add shouldBeInlined method to ResolvedJavaMethod, implement it for HotSpot and use it in the inlining phase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13692
diff changeset
416 return concrete.shouldBeInlined();
d587baa55dd7 Add shouldBeInlined method to ResolvedJavaMethod, implement it for HotSpot and use it in the inlining phase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13692
diff changeset
417 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
418 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
419
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
420 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
421 * Represents an inlining opportunity for which profiling information suggests a monomorphic
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
422 * receiver, but for which the receiver type cannot be proven. A type check guard will be
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
423 * generated if this inlining is performed.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
424 */
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
425 private static class TypeGuardInlineInfo extends AbstractInlineInfo {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
426
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
427 private final ResolvedJavaMethod concrete;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
428 private final ResolvedJavaType type;
9921
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
429 private Inlineable inlineableElement;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
430
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
431 public TypeGuardInlineInfo(Invoke invoke, ResolvedJavaMethod concrete, ResolvedJavaType type) {
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
432 super(invoke);
4451
defa1b705f14 NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4449
diff changeset
433 this.concrete = concrete;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
434 this.type = type;
13196
e343d4623e47 weakened assertion around type profiles to allow array types (GRAAL-618)
Doug Simon <doug.simon@oracle.com>
parents: 13166
diff changeset
435 assert type.isArray() || !isAbstract(type.getModifiers()) : type;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
436 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
437
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
438 @Override
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
439 public int numberOfMethods() {
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
440 return 1;
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
441 }
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
442
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
443 @Override
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
444 public ResolvedJavaMethod methodAt(int index) {
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
445 assert index == 0;
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
446 return concrete;
4528
e6e14d25e608 added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4473
diff changeset
447 }
e6e14d25e608 added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4473
diff changeset
448
e6e14d25e608 added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4473
diff changeset
449 @Override
9921
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
450 public Inlineable inlineableElementAt(int index) {
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
451 assert index == 0;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
452 return inlineableElement;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
453 }
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
454
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
455 @Override
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
456 public double probabilityAt(int index) {
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
457 assert index == 0;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
458 return 1.0;
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
459 }
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
460
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
461 @Override
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
462 public double relevanceAt(int index) {
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
463 assert index == 0;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
464 return 1.0;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
465 }
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
466
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
467 @Override
9921
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
468 public void setInlinableElement(int index, Inlineable inlineableElement) {
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
469 assert index == 0;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
470 this.inlineableElement = inlineableElement;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
471 }
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
472
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
473 @Override
12054
bba234a1670e grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12052
diff changeset
474 public void inline(Providers providers, Assumptions assumptions) {
bba234a1670e grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12052
diff changeset
475 createGuard(graph(), providers.getMetaAccess());
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
476 inline(invoke, concrete, inlineableElement, assumptions, false);
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
477 }
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
478
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
479 @Override
11959
23ccaa863eda made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11878
diff changeset
480 public void tryToDevirtualizeInvoke(MetaAccessProvider metaAccess, Assumptions assumptions) {
23ccaa863eda made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11878
diff changeset
481 createGuard(graph(), metaAccess);
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
482 replaceInvokeCallTarget(invoke, graph(), InvokeKind.Special, concrete);
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
483 }
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
484
11959
23ccaa863eda made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11878
diff changeset
485 private void createGuard(StructuredGraph graph, MetaAccessProvider metaAccess) {
10637
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
486 ValueNode nonNullReceiver = InliningUtil.nonNullReceiver(invoke);
11959
23ccaa863eda made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11878
diff changeset
487 ConstantNode typeHub = ConstantNode.forConstant(type.getEncoding(Representation.ObjectHub), metaAccess, graph);
14633
da2431cc1506 Rename ValueNode kind() to getKind().
Josef Eisl <josef.eisl@jku.at>
parents: 14558
diff changeset
488 LoadHubNode receiverHub = graph.unique(new LoadHubNode(nonNullReceiver, typeHub.getKind(), null));
10637
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
489
12655
2c4aa758ee18 made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12054
diff changeset
490 CompareNode typeCheck = CompareNode.createCompareNode(graph, Condition.EQ, receiverHub, typeHub);
7660
0b646334c5f7 keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents: 7558
diff changeset
491 FixedGuardNode guard = graph.add(new FixedGuardNode(typeCheck, DeoptimizationReason.TypeCheckedInliningViolated, DeoptimizationAction.InvalidateReprofile));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
492 assert invoke.predecessor() != null;
4453
c0430421d43d bugfixes for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4452
diff changeset
493
10637
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
494 ValueNode anchoredReceiver = createAnchoredReceiver(graph, guard, type, nonNullReceiver, true);
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
495 invoke.callTarget().replaceFirstInput(nonNullReceiver, anchoredReceiver);
4622
00e01f401c03 Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4618
diff changeset
496
9089
5ab06146e985 Rename "node()" methods in interfaces to "asNode"
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9004
diff changeset
497 graph.addBeforeFixed(invoke.asNode(), guard);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
498 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
499
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
500 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
501 public String toString() {
7213
ceb8c5b29419 print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7098
diff changeset
502 return "type-checked with type " + type.getName() + " and method " + MetaUtil.format("%H.%n(%p):%r", concrete);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
503 }
13953
d587baa55dd7 Add shouldBeInlined method to ResolvedJavaMethod, implement it for HotSpot and use it in the inlining phase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13692
diff changeset
504
d587baa55dd7 Add shouldBeInlined method to ResolvedJavaMethod, implement it for HotSpot and use it in the inlining phase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13692
diff changeset
505 public boolean shouldInline() {
d587baa55dd7 Add shouldBeInlined method to ResolvedJavaMethod, implement it for HotSpot and use it in the inlining phase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13692
diff changeset
506 return concrete.shouldBeInlined();
d587baa55dd7 Add shouldBeInlined method to ResolvedJavaMethod, implement it for HotSpot and use it in the inlining phase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13692
diff changeset
507 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
508 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
509
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
510 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
511 * Polymorphic inlining of m methods with n type checks (n >= m) in case that the profiling
10637
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
512 * information suggests a reasonable amount of different receiver types and different methods.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
513 * If an unknown type is encountered a deoptimization is triggered.
4451
defa1b705f14 NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4449
diff changeset
514 */
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
515 private static class MultiTypeGuardInlineInfo extends AbstractInlineInfo {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
516
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
517 private final List<ResolvedJavaMethod> concretes;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
518 private final double[] methodProbabilities;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
519 private final double maximumMethodProbability;
9704
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701 9610
diff changeset
520 private final ArrayList<Integer> typesToConcretes;
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
521 private final ArrayList<ProfiledType> ptypes;
9380
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
522 private final ArrayList<Double> concretesProbabilities;
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
523 private final double notRecordedTypeProbability;
9921
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
524 private final Inlineable[] inlineableElements;
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
525
9392
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
526 public MultiTypeGuardInlineInfo(Invoke invoke, ArrayList<ResolvedJavaMethod> concretes, ArrayList<Double> concretesProbabilities, ArrayList<ProfiledType> ptypes,
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
527 ArrayList<Integer> typesToConcretes, double notRecordedTypeProbability) {
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
528 super(invoke);
9392
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
529 assert concretes.size() > 0 : "must have at least one method";
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
530 assert ptypes.size() == typesToConcretes.size() : "array lengths must match";
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
531
9380
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
532 this.concretesProbabilities = concretesProbabilities;
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
533 this.concretes = concretes;
5335
439ca5ecc7dc types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents: 5316
diff changeset
534 this.ptypes = ptypes;
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
535 this.typesToConcretes = typesToConcretes;
4472
63cd21fda79b hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4467
diff changeset
536 this.notRecordedTypeProbability = notRecordedTypeProbability;
9921
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
537 this.inlineableElements = new Inlineable[concretes.size()];
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
538 this.methodProbabilities = computeMethodProbabilities();
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
539 this.maximumMethodProbability = maximumMethodProbability();
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
540 assert maximumMethodProbability > 0;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
541 }
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
542
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
543 private double[] computeMethodProbabilities() {
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
544 double[] result = new double[concretes.size()];
9705
de7319e48e48 Temporary fixes for the merge.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9704
diff changeset
545 for (int i = 0; i < typesToConcretes.size(); i++) {
de7319e48e48 Temporary fixes for the merge.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9704
diff changeset
546 int concrete = typesToConcretes.get(i);
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
547 double probability = ptypes.get(i).getProbability();
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
548 result[concrete] += probability;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
549 }
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
550 return result;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
551 }
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
552
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
553 private double maximumMethodProbability() {
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
554 double max = 0;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
555 for (int i = 0; i < methodProbabilities.length; i++) {
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
556 max = Math.max(max, methodProbabilities[i]);
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
557 }
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
558 return max;
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
559 }
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
560
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
561 @Override
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
562 public int numberOfMethods() {
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
563 return concretes.size();
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
564 }
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
565
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
566 @Override
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
567 public ResolvedJavaMethod methodAt(int index) {
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
568 assert index >= 0 && index < concretes.size();
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
569 return concretes.get(index);
4528
e6e14d25e608 added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4473
diff changeset
570 }
e6e14d25e608 added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4473
diff changeset
571
e6e14d25e608 added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4473
diff changeset
572 @Override
9921
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
573 public Inlineable inlineableElementAt(int index) {
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
574 assert index >= 0 && index < concretes.size();
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
575 return inlineableElements[index];
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
576 }
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
577
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
578 @Override
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
579 public double probabilityAt(int index) {
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
580 return methodProbabilities[index];
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
581 }
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
582
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
583 @Override
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
584 public double relevanceAt(int index) {
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
585 return probabilityAt(index) / maximumMethodProbability;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
586 }
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
587
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
588 @Override
9921
26785bb7006d Refactorings for the InliningPhase.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9722
diff changeset
589 public void setInlinableElement(int index, Inlineable inlineableElement) {
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
590 assert index >= 0 && index < concretes.size();
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
591 inlineableElements[index] = inlineableElement;
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
592 }
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
593
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
594 @Override
12054
bba234a1670e grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12052
diff changeset
595 public void inline(Providers providers, Assumptions assumptions) {
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
596 if (hasSingleMethod()) {
12054
bba234a1670e grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12052
diff changeset
597 inlineSingleMethod(graph(), providers.getMetaAccess(), assumptions);
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
598 } else {
12054
bba234a1670e grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12052
diff changeset
599 inlineMultipleMethods(graph(), providers, assumptions);
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
600 }
4472
63cd21fda79b hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4467
diff changeset
601 }
63cd21fda79b hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4467
diff changeset
602
13953
d587baa55dd7 Add shouldBeInlined method to ResolvedJavaMethod, implement it for HotSpot and use it in the inlining phase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13692
diff changeset
603 public boolean shouldInline() {
d587baa55dd7 Add shouldBeInlined method to ResolvedJavaMethod, implement it for HotSpot and use it in the inlining phase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13692
diff changeset
604 for (ResolvedJavaMethod method : concretes) {
d587baa55dd7 Add shouldBeInlined method to ResolvedJavaMethod, implement it for HotSpot and use it in the inlining phase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13692
diff changeset
605 if (method.shouldBeInlined()) {
d587baa55dd7 Add shouldBeInlined method to ResolvedJavaMethod, implement it for HotSpot and use it in the inlining phase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13692
diff changeset
606 return true;
d587baa55dd7 Add shouldBeInlined method to ResolvedJavaMethod, implement it for HotSpot and use it in the inlining phase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13692
diff changeset
607 }
d587baa55dd7 Add shouldBeInlined method to ResolvedJavaMethod, implement it for HotSpot and use it in the inlining phase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13692
diff changeset
608 }
d587baa55dd7 Add shouldBeInlined method to ResolvedJavaMethod, implement it for HotSpot and use it in the inlining phase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13692
diff changeset
609 return false;
d587baa55dd7 Add shouldBeInlined method to ResolvedJavaMethod, implement it for HotSpot and use it in the inlining phase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13692
diff changeset
610 }
d587baa55dd7 Add shouldBeInlined method to ResolvedJavaMethod, implement it for HotSpot and use it in the inlining phase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13692
diff changeset
611
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
612 private boolean hasSingleMethod() {
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
613 return concretes.size() == 1 && !shouldFallbackToInvoke();
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
614 }
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
615
4472
63cd21fda79b hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4467
diff changeset
616 private boolean shouldFallbackToInvoke() {
63cd21fda79b hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4467
diff changeset
617 return notRecordedTypeProbability > 0;
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
618 }
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
619
12054
bba234a1670e grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12052
diff changeset
620 private void inlineMultipleMethods(StructuredGraph graph, Providers providers, Assumptions assumptions) {
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
621 int numberOfMethods = concretes.size();
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
622 FixedNode continuation = invoke.next();
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
623
9147
07f05f2a8149 Remove methodCallTarget() method from the Invoke interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9089
diff changeset
624 ValueNode originalReceiver = ((MethodCallTargetNode) invoke.callTarget()).receiver();
4456
f4c82dd4619e inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4455
diff changeset
625 // setup merge and phi nodes for results and exceptions
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
626 MergeNode returnMerge = graph.add(new MergeNode());
11669
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11657
diff changeset
627 returnMerge.setStateAfter(invoke.stateAfter());
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
628
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
629 PhiNode returnValuePhi = null;
14633
da2431cc1506 Rename ValueNode kind() to getKind().
Josef Eisl <josef.eisl@jku.at>
parents: 14558
diff changeset
630 if (invoke.asNode().getKind() != Kind.Void) {
14558
fabf5447603e Use stamp constructor in PhiNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 14172
diff changeset
631 returnValuePhi = graph.addWithoutUnique(new PhiNode(invoke.asNode().stamp().unrestricted(), returnMerge));
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
632 }
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
633
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
634 MergeNode exceptionMerge = null;
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
635 PhiNode exceptionObjectPhi = null;
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
636 if (invoke instanceof InvokeWithExceptionNode) {
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
637 InvokeWithExceptionNode invokeWithException = (InvokeWithExceptionNode) invoke;
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
638 ExceptionObjectNode exceptionEdge = (ExceptionObjectNode) invokeWithException.exceptionEdge();
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
639
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
640 exceptionMerge = graph.add(new MergeNode());
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
641
8441
21bf57680185 Fuse the ExceptionObject its DispatchBegin into a single node since it has to be atomic while gurads are floating
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8421
diff changeset
642 FixedNode exceptionSux = exceptionEdge.next();
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
643 graph.addBeforeFixed(exceptionSux, exceptionMerge);
14558
fabf5447603e Use stamp constructor in PhiNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 14172
diff changeset
644 exceptionObjectPhi = graph.addWithoutUnique(new PhiNode(StampFactory.forKind(Kind.Object), exceptionMerge));
8469
718c0304ffeb Fix for polymorphic inlining after fusing exception obecjt and the distaptch begin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8461
diff changeset
645 exceptionMerge.setStateAfter(exceptionEdge.stateAfter().duplicateModified(invoke.stateAfter().bci, true, Kind.Object, exceptionObjectPhi));
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
646 }
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
647
4456
f4c82dd4619e inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4455
diff changeset
648 // create one separate block for each invoked method
9436
ae815a4c112a Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9434
diff changeset
649 AbstractBeginNode[] successors = new AbstractBeginNode[numberOfMethods + 1];
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
650 for (int i = 0; i < numberOfMethods; i++) {
9234
b9cf7d0b598e removal of FixedNode.probability (draft)
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9147
diff changeset
651 successors[i] = createInvocationBlock(graph, invoke, returnMerge, returnValuePhi, exceptionMerge, exceptionObjectPhi, true);
4472
63cd21fda79b hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4467
diff changeset
652 }
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
653
4472
63cd21fda79b hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4467
diff changeset
654 // create the successor for an unknown type
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
655 FixedNode unknownTypeSux;
4472
63cd21fda79b hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4467
diff changeset
656 if (shouldFallbackToInvoke()) {
9234
b9cf7d0b598e removal of FixedNode.probability (draft)
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9147
diff changeset
657 unknownTypeSux = createInvocationBlock(graph, invoke, returnMerge, returnValuePhi, exceptionMerge, exceptionObjectPhi, false);
4472
63cd21fda79b hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4467
diff changeset
658 } else {
7660
0b646334c5f7 keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents: 7558
diff changeset
659 unknownTypeSux = graph.add(new DeoptimizeNode(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.TypeCheckedInliningViolated));
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
660 }
9436
ae815a4c112a Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9434
diff changeset
661 successors[successors.length - 1] = AbstractBeginNode.begin(unknownTypeSux);
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
662
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
663 // replace the invoke exception edge
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
664 if (invoke instanceof InvokeWithExceptionNode) {
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
665 InvokeWithExceptionNode invokeWithExceptionNode = (InvokeWithExceptionNode) invoke;
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
666 ExceptionObjectNode exceptionEdge = (ExceptionObjectNode) invokeWithExceptionNode.exceptionEdge();
8441
21bf57680185 Fuse the ExceptionObject its DispatchBegin into a single node since it has to be atomic while gurads are floating
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8421
diff changeset
667 exceptionEdge.replaceAtUsages(exceptionObjectPhi);
21bf57680185 Fuse the ExceptionObject its DispatchBegin into a single node since it has to be atomic while gurads are floating
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8421
diff changeset
668 exceptionEdge.setNext(null);
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
669 GraphUtil.killCFG(invokeWithExceptionNode.exceptionEdge());
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
670 }
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
671
9089
5ab06146e985 Rename "node()" methods in interfaces to "asNode"
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9004
diff changeset
672 assert invoke.asNode().isAlive();
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
673
5786
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
674 // replace the invoke with a switch on the type of the actual receiver
12054
bba234a1670e grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12052
diff changeset
675 boolean methodDispatch = createDispatchOnTypeBeforeInvoke(graph, successors, false, providers.getMetaAccess());
4458
cdf13998f705 inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4457
diff changeset
676
cdf13998f705 inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4457
diff changeset
677 assert invoke.next() == continuation;
cdf13998f705 inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4457
diff changeset
678 invoke.setNext(null);
cdf13998f705 inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4457
diff changeset
679 returnMerge.setNext(continuation);
9089
5ab06146e985 Rename "node()" methods in interfaces to "asNode"
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9004
diff changeset
680 invoke.asNode().replaceAtUsages(returnValuePhi);
5ab06146e985 Rename "node()" methods in interfaces to "asNode"
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9004
diff changeset
681 invoke.asNode().replaceAndDelete(null);
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
682
10706
8d961f93725c Use GuardedValueNode in the inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10692
diff changeset
683 ArrayList<GuardedValueNode> replacementNodes = new ArrayList<>();
5786
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
684
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
685 // do the actual inlining for every invoke
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
686 for (int i = 0; i < numberOfMethods; i++) {
9436
ae815a4c112a Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9434
diff changeset
687 AbstractBeginNode node = successors[i];
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
688 Invoke invokeForInlining = (Invoke) node.next();
4636
495a81cd6969 avoid code generation for typechecks that are only used for anchoring
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4635
diff changeset
689
9380
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
690 ResolvedJavaType commonType;
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
691 if (methodDispatch) {
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
692 commonType = concretes.get(i).getDeclaringClass();
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
693 } else {
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
694 commonType = getLeastCommonType(i);
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
695 }
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
696
9147
07f05f2a8149 Remove methodCallTarget() method from the Invoke interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9089
diff changeset
697 ValueNode receiver = ((MethodCallTargetNode) invokeForInlining.callTarget()).receiver();
9380
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
698 boolean exact = (getTypeCount(i) == 1 && !methodDispatch);
10706
8d961f93725c Use GuardedValueNode in the inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10692
diff changeset
699 GuardedValueNode anchoredReceiver = createAnchoredReceiver(graph, node, commonType, receiver, exact);
5339
e8f80481326d use PiNodes instead of CheckCastNodes to pin inlining receivers, remove emitCode flag
Lukas Stadler <lukas.stadler@jku.at>
parents: 5316
diff changeset
700 invokeForInlining.callTarget().replaceFirstInput(receiver, anchoredReceiver);
4622
00e01f401c03 Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4618
diff changeset
701
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
702 inline(invokeForInlining, methodAt(i), inlineableElementAt(i), assumptions, false);
7510
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
703
8636
ac4dbfecec8f passed a Replacements object to inlining utility methods that need one instead of the GraalRuntime API
Doug Simon <doug.simon@oracle.com>
parents: 8627
diff changeset
704 replacementNodes.add(anchoredReceiver);
5786
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
705 }
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
706 if (shouldFallbackToInvoke()) {
8636
ac4dbfecec8f passed a Replacements object to inlining utility methods that need one instead of the GraalRuntime API
Doug Simon <doug.simon@oracle.com>
parents: 8627
diff changeset
707 replacementNodes.add(null);
5786
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
708 }
9374
8649dbda7d25 New experiment with megamorphic inlining.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9329
diff changeset
709
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9837
diff changeset
710 if (OptTailDuplication.getValue()) {
5786
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
711 /*
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
712 * We might want to perform tail duplication at the merge after a type switch, if
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
713 * there are invokes that would benefit from the improvement in type information.
5786
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
714 */
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
715 FixedNode current = returnMerge;
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
716 int opportunities = 0;
5791
506e76281145 (symptomatic) fix for NPE in InliningUtil
Lukas Stadler <lukas.stadler@jku.at>
parents: 5786
diff changeset
717 do {
9147
07f05f2a8149 Remove methodCallTarget() method from the Invoke interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9089
diff changeset
718 if (current instanceof InvokeNode && ((InvokeNode) current).callTarget() instanceof MethodCallTargetNode &&
07f05f2a8149 Remove methodCallTarget() method from the Invoke interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9089
diff changeset
719 ((MethodCallTargetNode) ((InvokeNode) current).callTarget()).receiver() == originalReceiver) {
5786
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
720 opportunities++;
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
721 } else if (current.inputs().contains(originalReceiver)) {
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
722 opportunities++;
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
723 }
5791
506e76281145 (symptomatic) fix for NPE in InliningUtil
Lukas Stadler <lukas.stadler@jku.at>
parents: 5786
diff changeset
724 current = ((FixedWithNextNode) current).next();
506e76281145 (symptomatic) fix for NPE in InliningUtil
Lukas Stadler <lukas.stadler@jku.at>
parents: 5786
diff changeset
725 } while (current instanceof FixedWithNextNode);
9705
de7319e48e48 Temporary fixes for the merge.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9704
diff changeset
726
5786
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
727 if (opportunities > 0) {
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
728 metricInliningTailDuplication.increment();
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
729 Debug.log("MultiTypeGuardInlineInfo starting tail duplication (%d opportunities)", opportunities);
12054
bba234a1670e grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12052
diff changeset
730 PhaseContext phaseContext = new PhaseContext(providers, assumptions);
13378
16d99e9d77ad Options: rename flag (AOTCompilation -> ImmutableCode)
Bernhard Urban <bernhard.urban@jku.at>
parents: 13327
diff changeset
731 CanonicalizerPhase canonicalizer = new CanonicalizerPhase(!ImmutableCode.getValue());
12054
bba234a1670e grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12052
diff changeset
732 TailDuplicationPhase.tailDuplicate(returnMerge, TailDuplicationPhase.TRUE_DECISION, replacementNodes, phaseContext, canonicalizer);
5786
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5720
diff changeset
733 }
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
734 }
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
735 }
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
736
6289
72eb3a1a20c4 create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents: 5792
diff changeset
737 private int getTypeCount(int concreteMethodIndex) {
72eb3a1a20c4 create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents: 5792
diff changeset
738 int count = 0;
9392
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
739 for (int i = 0; i < typesToConcretes.size(); i++) {
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
740 if (typesToConcretes.get(i) == concreteMethodIndex) {
6289
72eb3a1a20c4 create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents: 5792
diff changeset
741 count++;
72eb3a1a20c4 create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents: 5792
diff changeset
742 }
72eb3a1a20c4 create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents: 5792
diff changeset
743 }
72eb3a1a20c4 create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents: 5792
diff changeset
744 return count;
72eb3a1a20c4 create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents: 5792
diff changeset
745 }
72eb3a1a20c4 create PiNodes with exact types during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents: 5792
diff changeset
746
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
747 private ResolvedJavaType getLeastCommonType(int concreteMethodIndex) {
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
748 ResolvedJavaType commonType = null;
9392
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
749 for (int i = 0; i < typesToConcretes.size(); i++) {
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
750 if (typesToConcretes.get(i) == concreteMethodIndex) {
4635
f35c183f33ce fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4627
diff changeset
751 if (commonType == null) {
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
752 commonType = ptypes.get(i).getType();
4635
f35c183f33ce fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4627
diff changeset
753 } else {
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
754 commonType = commonType.findLeastCommonAncestor(ptypes.get(i).getType());
4635
f35c183f33ce fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4627
diff changeset
755 }
f35c183f33ce fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4627
diff changeset
756 }
f35c183f33ce fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4627
diff changeset
757 }
f35c183f33ce fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4627
diff changeset
758 assert commonType != null;
f35c183f33ce fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4627
diff changeset
759 return commonType;
f35c183f33ce fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4627
diff changeset
760 }
f35c183f33ce fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4627
diff changeset
761
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
762 private ResolvedJavaType getLeastCommonType() {
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
763 ResolvedJavaType result = getLeastCommonType(0);
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
764 for (int i = 1; i < concretes.size(); i++) {
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
765 result = result.findLeastCommonAncestor(getLeastCommonType(i));
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
766 }
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
767 return result;
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
768 }
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
769
11959
23ccaa863eda made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11878
diff changeset
770 private void inlineSingleMethod(StructuredGraph graph, MetaAccessProvider metaAccess, Assumptions assumptions) {
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
771 assert concretes.size() == 1 && inlineableElements.length == 1 && ptypes.size() > 1 && !shouldFallbackToInvoke() && notRecordedTypeProbability == 0;
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
772
9436
ae815a4c112a Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9434
diff changeset
773 AbstractBeginNode calleeEntryNode = graph.add(new BeginNode());
4459
d389f4b5bdd6 fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4458
diff changeset
774
9436
ae815a4c112a Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9434
diff changeset
775 AbstractBeginNode unknownTypeSux = createUnknownTypeSuccessor(graph);
ae815a4c112a Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9434
diff changeset
776 AbstractBeginNode[] successors = new AbstractBeginNode[]{calleeEntryNode, unknownTypeSux};
11959
23ccaa863eda made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11878
diff changeset
777 createDispatchOnTypeBeforeInvoke(graph, successors, false, metaAccess);
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
778
9089
5ab06146e985 Rename "node()" methods in interfaces to "asNode"
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9004
diff changeset
779 calleeEntryNode.setNext(invoke.asNode());
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
780
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
781 inline(invoke, methodAt(0), inlineableElementAt(0), assumptions, false);
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
782 }
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
783
11959
23ccaa863eda made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11878
diff changeset
784 private boolean createDispatchOnTypeBeforeInvoke(StructuredGraph graph, AbstractBeginNode[] successors, boolean invokeIsOnlySuccessor, MetaAccessProvider metaAccess) {
9374
8649dbda7d25 New experiment with megamorphic inlining.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9329
diff changeset
785 assert ptypes.size() >= 1;
10637
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
786 ValueNode nonNullReceiver = nonNullReceiver(invoke);
9147
07f05f2a8149 Remove methodCallTarget() method from the Invoke interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9089
diff changeset
787 Kind hubKind = ((MethodCallTargetNode) invoke.callTarget()).targetMethod().getDeclaringClass().getEncoding(Representation.ObjectHub).getKind();
11652
f091e0d6f4f3 Disallow add for global value numberable node types. Introduce addWithoutUnique.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11573
diff changeset
788 LoadHubNode hub = graph.unique(new LoadHubNode(nonNullReceiver, hubKind, null));
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
789
9380
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
790 if (!invokeIsOnlySuccessor && chooseMethodDispatch()) {
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
791 assert successors.length == concretes.size() + 1;
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
792 assert concretes.size() > 0;
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
793 Debug.log("Method check cascade with %d methods", concretes.size());
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
794
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
795 ValueNode[] constantMethods = new ValueNode[concretes.size()];
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
796 double[] probability = new double[concretes.size()];
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
797 for (int i = 0; i < concretes.size(); ++i) {
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
798 ResolvedJavaMethod firstMethod = concretes.get(i);
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
799 Constant firstMethodConstant = firstMethod.getEncoding();
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
800
11959
23ccaa863eda made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11878
diff changeset
801 ValueNode firstMethodConstantNode = ConstantNode.forConstant(firstMethodConstant, metaAccess, graph);
9380
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
802 constantMethods[i] = firstMethodConstantNode;
9467
3531cdfddff6 Ensure probabilities are never negative. Add additional assertions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9436
diff changeset
803 double concretesProbability = concretesProbabilities.get(i);
3531cdfddff6 Ensure probabilities are never negative. Add additional assertions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9436
diff changeset
804 assert concretesProbability >= 0.0;
3531cdfddff6 Ensure probabilities are never negative. Add additional assertions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9436
diff changeset
805 probability[i] = concretesProbability;
9380
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
806 if (i > 0) {
9469
8c37649cbb62 Fixes for probability calculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9467
diff changeset
807 double prevProbability = probability[i - 1];
8c37649cbb62 Fixes for probability calculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9467
diff changeset
808 if (prevProbability == 1.0) {
8c37649cbb62 Fixes for probability calculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9467
diff changeset
809 probability[i] = 1.0;
8c37649cbb62 Fixes for probability calculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9467
diff changeset
810 } else {
9470
225fc5463430 Make sure if trueSuccessor probability is always <= 1.0.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9469
diff changeset
811 probability[i] = Math.min(1.0, Math.max(0.0, probability[i] / (1.0 - prevProbability)));
9469
8c37649cbb62 Fixes for probability calculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9467
diff changeset
812 }
9380
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
813 }
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
814 }
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
815
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
816 FixedNode lastSucc = successors[concretes.size()];
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
817 for (int i = concretes.size() - 1; i >= 0; --i) {
14633
da2431cc1506 Rename ValueNode kind() to getKind().
Josef Eisl <josef.eisl@jku.at>
parents: 14558
diff changeset
818 LoadMethodNode method = graph.add(new LoadMethodNode(concretes.get(i), hub, constantMethods[i].getKind()));
12655
2c4aa758ee18 made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12054
diff changeset
819 CompareNode methodCheck = CompareNode.createCompareNode(graph, Condition.EQ, method, constantMethods[i]);
9380
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
820 IfNode ifNode = graph.add(new IfNode(methodCheck, successors[i], lastSucc, probability[i]));
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
821 method.setNext(ifNode);
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
822 lastSucc = method;
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
823 }
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
824
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
825 FixedWithNextNode pred = (FixedWithNextNode) invoke.asNode().predecessor();
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
826 pred.setNext(lastSucc);
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
827 return true;
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
828 } else {
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
829 Debug.log("Type switch with %d types", concretes.size());
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
830 }
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
831
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
832 ResolvedJavaType[] keys = new ResolvedJavaType[ptypes.size()];
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
833 double[] keyProbabilities = new double[ptypes.size() + 1];
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
834 int[] keySuccessors = new int[ptypes.size() + 1];
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
835 for (int i = 0; i < ptypes.size(); i++) {
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
836 keys[i] = ptypes.get(i).getType();
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
837 keyProbabilities[i] = ptypes.get(i).getProbability();
9392
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
838 keySuccessors[i] = invokeIsOnlySuccessor ? 0 : typesToConcretes.get(i);
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
839 assert keySuccessors[i] < successors.length - 1 : "last successor is the unknownTypeSux";
4459
d389f4b5bdd6 fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4458
diff changeset
840 }
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
841 keyProbabilities[keyProbabilities.length - 1] = notRecordedTypeProbability;
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
842 keySuccessors[keySuccessors.length - 1] = successors.length - 1;
4459
d389f4b5bdd6 fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4458
diff changeset
843
7705
96a596d751ab remove successorProbabilities from SwitchNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
844 TypeSwitchNode typeSwitch = graph.add(new TypeSwitchNode(hub, successors, keys, keyProbabilities, keySuccessors));
9089
5ab06146e985 Rename "node()" methods in interfaces to "asNode"
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9004
diff changeset
845 FixedWithNextNode pred = (FixedWithNextNode) invoke.asNode().predecessor();
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
846 pred.setNext(typeSwitch);
9380
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
847 return false;
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
848 }
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
849
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
850 private boolean chooseMethodDispatch() {
9610
ae17e540c5d2 More asserts while getting vtable offsets
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9602
diff changeset
851 for (ResolvedJavaMethod concrete : concretes) {
ae17e540c5d2 More asserts while getting vtable offsets
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9602
diff changeset
852 if (!concrete.isInVirtualMethodTable()) {
ae17e540c5d2 More asserts while getting vtable offsets
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9602
diff changeset
853 return false;
ae17e540c5d2 More asserts while getting vtable offsets
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9602
diff changeset
854 }
ae17e540c5d2 More asserts while getting vtable offsets
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9602
diff changeset
855 }
ae17e540c5d2 More asserts while getting vtable offsets
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9602
diff changeset
856
9380
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
857 if (concretes.size() == 1 && this.notRecordedTypeProbability > 0) {
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
858 // Always chose method dispatch if there is a single concrete method and the call
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
859 // site is megamorphic.
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
860 return true;
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
861 }
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
862
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
863 if (concretes.size() == ptypes.size()) {
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
864 // Always prefer types over methods if the number of types is smaller than the
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
865 // number of methods.
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
866 return false;
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
867 }
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
868
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
869 return chooseMethodDispatchCostBased();
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
870 }
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
871
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
872 private boolean chooseMethodDispatchCostBased() {
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
873 double remainder = 1.0 - this.notRecordedTypeProbability;
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
874 double costEstimateMethodDispatch = remainder;
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
875 for (int i = 0; i < concretes.size(); ++i) {
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
876 if (i != 0) {
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
877 costEstimateMethodDispatch += remainder;
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
878 }
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
879 remainder -= concretesProbabilities.get(i);
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
880 }
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
881
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
882 double costEstimateTypeDispatch = 0.0;
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
883 remainder = 1.0;
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
884 for (int i = 0; i < ptypes.size(); ++i) {
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
885 if (i != 0) {
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
886 costEstimateTypeDispatch += remainder;
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
887 }
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
888 remainder -= ptypes.get(i).getProbability();
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
889 }
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
890 costEstimateTypeDispatch += notRecordedTypeProbability;
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
891 return costEstimateMethodDispatch < costEstimateTypeDispatch;
4454
008a5ea590ca fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4453
diff changeset
892 }
008a5ea590ca fixed merge control flow for inlining
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4453
diff changeset
893
9436
ae815a4c112a Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9434
diff changeset
894 private static AbstractBeginNode createInvocationBlock(StructuredGraph graph, Invoke invoke, MergeNode returnMerge, PhiNode returnValuePhi, MergeNode exceptionMerge,
ae815a4c112a Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9434
diff changeset
895 PhiNode exceptionObjectPhi, boolean useForInlining) {
9234
b9cf7d0b598e removal of FixedNode.probability (draft)
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9147
diff changeset
896 Invoke duplicatedInvoke = duplicateInvokeForInlining(graph, invoke, exceptionMerge, exceptionObjectPhi, useForInlining);
9436
ae815a4c112a Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9434
diff changeset
897 AbstractBeginNode calleeEntryNode = graph.add(new BeginNode());
9089
5ab06146e985 Rename "node()" methods in interfaces to "asNode"
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9004
diff changeset
898 calleeEntryNode.setNext(duplicatedInvoke.asNode());
4472
63cd21fda79b hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4467
diff changeset
899
9434
50f02c7d1cec Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9392
diff changeset
900 AbstractEndNode endNode = graph.add(new EndNode());
4472
63cd21fda79b hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4467
diff changeset
901 duplicatedInvoke.setNext(endNode);
4614
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4571
diff changeset
902 returnMerge.addForwardEnd(endNode);
5005
c2ebd3d559f7 fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5003
diff changeset
903
4472
63cd21fda79b hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4467
diff changeset
904 if (returnValuePhi != null) {
9089
5ab06146e985 Rename "node()" methods in interfaces to "asNode"
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9004
diff changeset
905 returnValuePhi.addInput(duplicatedInvoke.asNode());
4472
63cd21fda79b hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4467
diff changeset
906 }
63cd21fda79b hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4467
diff changeset
907 return calleeEntryNode;
63cd21fda79b hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4467
diff changeset
908 }
63cd21fda79b hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4467
diff changeset
909
9234
b9cf7d0b598e removal of FixedNode.probability (draft)
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9147
diff changeset
910 private static Invoke duplicateInvokeForInlining(StructuredGraph graph, Invoke invoke, MergeNode exceptionMerge, PhiNode exceptionObjectPhi, boolean useForInlining) {
9089
5ab06146e985 Rename "node()" methods in interfaces to "asNode"
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9004
diff changeset
911 Invoke result = (Invoke) invoke.asNode().copyWithInputs();
4622
00e01f401c03 Add checkcast for type-guarded inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4618
diff changeset
912 Node callTarget = result.callTarget().copyWithInputs();
9089
5ab06146e985 Rename "node()" methods in interfaces to "asNode"
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9004
diff changeset
913 result.asNode().replaceFirstInput(result.callTarget(), callTarget);
4472
63cd21fda79b hotspot gc bugfix, added possibility to fallback to invocation if type check is violated
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4467
diff changeset
914 result.setUseForInlining(useForInlining);
4539
98b3b255913c Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4530
diff changeset
915
14633
da2431cc1506 Rename ValueNode kind() to getKind().
Josef Eisl <josef.eisl@jku.at>
parents: 14558
diff changeset
916 Kind kind = invoke.asNode().getKind();
7098
e23980f4a890 Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7097
diff changeset
917 if (kind != Kind.Void) {
4539
98b3b255913c Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4530
diff changeset
918 FrameState stateAfter = invoke.stateAfter();
98b3b255913c Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4530
diff changeset
919 stateAfter = stateAfter.duplicate(stateAfter.bci);
9089
5ab06146e985 Rename "node()" methods in interfaces to "asNode"
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9004
diff changeset
920 stateAfter.replaceFirstInput(invoke.asNode(), result.asNode());
4539
98b3b255913c Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4530
diff changeset
921 result.setStateAfter(stateAfter);
98b3b255913c Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4530
diff changeset
922 }
98b3b255913c Fix stateAfter for multiple type inline
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4530
diff changeset
923
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
924 if (invoke instanceof InvokeWithExceptionNode) {
4458
cdf13998f705 inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4457
diff changeset
925 assert exceptionMerge != null && exceptionObjectPhi != null;
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
926
4458
cdf13998f705 inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4457
diff changeset
927 InvokeWithExceptionNode invokeWithException = (InvokeWithExceptionNode) invoke;
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
928 ExceptionObjectNode exceptionEdge = (ExceptionObjectNode) invokeWithException.exceptionEdge();
8441
21bf57680185 Fuse the ExceptionObject its DispatchBegin into a single node since it has to be atomic while gurads are floating
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8421
diff changeset
929 FrameState stateAfterException = exceptionEdge.stateAfter();
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
930
8441
21bf57680185 Fuse the ExceptionObject its DispatchBegin into a single node since it has to be atomic while gurads are floating
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8421
diff changeset
931 ExceptionObjectNode newExceptionEdge = (ExceptionObjectNode) exceptionEdge.copyWithInputs();
4529
fc78ad20ec38 fixed exception framestate
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4528
diff changeset
932 // set new state (pop old exception object, push new one)
8441
21bf57680185 Fuse the ExceptionObject its DispatchBegin into a single node since it has to be atomic while gurads are floating
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8421
diff changeset
933 newExceptionEdge.setStateAfter(stateAfterException.duplicateModified(stateAfterException.bci, stateAfterException.rethrowException(), Kind.Object, newExceptionEdge));
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
934
9434
50f02c7d1cec Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9392
diff changeset
935 AbstractEndNode endNode = graph.add(new EndNode());
8441
21bf57680185 Fuse the ExceptionObject its DispatchBegin into a single node since it has to be atomic while gurads are floating
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8421
diff changeset
936 newExceptionEdge.setNext(endNode);
4614
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4571
diff changeset
937 exceptionMerge.addForwardEnd(endNode);
8441
21bf57680185 Fuse the ExceptionObject its DispatchBegin into a single node since it has to be atomic while gurads are floating
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8421
diff changeset
938 exceptionObjectPhi.addInput(newExceptionEdge);
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
939
4458
cdf13998f705 inlining of multiple methods survives bootstrapping
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4457
diff changeset
940 ((InvokeWithExceptionNode) result).setExceptionEdge(newExceptionEdge);
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
941 }
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
942 return result;
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
943 }
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
944
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
945 @Override
11959
23ccaa863eda made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11878
diff changeset
946 public void tryToDevirtualizeInvoke(MetaAccessProvider metaAccess, Assumptions assumptions) {
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
947 if (hasSingleMethod()) {
11959
23ccaa863eda made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11878
diff changeset
948 devirtualizeWithTypeSwitch(graph(), InvokeKind.Special, concretes.get(0), metaAccess);
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
949 } else {
11959
23ccaa863eda made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11878
diff changeset
950 tryToDevirtualizeMultipleMethods(graph(), metaAccess);
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
951 }
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
952 }
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
953
11959
23ccaa863eda made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11878
diff changeset
954 private void tryToDevirtualizeMultipleMethods(StructuredGraph graph, MetaAccessProvider metaAccess) {
9147
07f05f2a8149 Remove methodCallTarget() method from the Invoke interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9089
diff changeset
955 MethodCallTargetNode methodCallTarget = (MethodCallTargetNode) invoke.callTarget();
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
956 if (methodCallTarget.invokeKind() == InvokeKind.Interface) {
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
957 ResolvedJavaMethod targetMethod = methodCallTarget.targetMethod();
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
958 ResolvedJavaType leastCommonType = getLeastCommonType();
7686
149092d59dd0 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7685
diff changeset
959 // check if we have a common base type that implements the interface -> in that case
7825
c6c3515bea8e New formatter settings for enum values (every value on a new line).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7818
diff changeset
960 // we have a vtable entry for the interface method and can use a less expensive
c6c3515bea8e New formatter settings for enum values (every value on a new line).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7818
diff changeset
961 // virtual call
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
962 if (!leastCommonType.isInterface() && targetMethod.getDeclaringClass().isAssignableFrom(leastCommonType)) {
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
963 ResolvedJavaMethod baseClassTargetMethod = leastCommonType.resolveMethod(targetMethod);
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
964 if (baseClassTargetMethod != null) {
11959
23ccaa863eda made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11878
diff changeset
965 devirtualizeWithTypeSwitch(graph, InvokeKind.Virtual, leastCommonType.resolveMethod(targetMethod), metaAccess);
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
966 }
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
967 }
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
968 }
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
969 }
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
970
11959
23ccaa863eda made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11878
diff changeset
971 private void devirtualizeWithTypeSwitch(StructuredGraph graph, InvokeKind kind, ResolvedJavaMethod target, MetaAccessProvider metaAccess) {
9436
ae815a4c112a Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9434
diff changeset
972 AbstractBeginNode invocationEntry = graph.add(new BeginNode());
ae815a4c112a Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9434
diff changeset
973 AbstractBeginNode unknownTypeSux = createUnknownTypeSuccessor(graph);
ae815a4c112a Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9434
diff changeset
974 AbstractBeginNode[] successors = new AbstractBeginNode[]{invocationEntry, unknownTypeSux};
11959
23ccaa863eda made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11878
diff changeset
975 createDispatchOnTypeBeforeInvoke(graph, successors, true, metaAccess);
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
976
9089
5ab06146e985 Rename "node()" methods in interfaces to "asNode"
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9004
diff changeset
977 invocationEntry.setNext(invoke.asNode());
9147
07f05f2a8149 Remove methodCallTarget() method from the Invoke interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9089
diff changeset
978 ValueNode receiver = ((MethodCallTargetNode) invoke.callTarget()).receiver();
10706
8d961f93725c Use GuardedValueNode in the inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10692
diff changeset
979 GuardedValueNode anchoredReceiver = createAnchoredReceiver(graph, invocationEntry, target.getDeclaringClass(), receiver, false);
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
980 invoke.callTarget().replaceFirstInput(receiver, anchoredReceiver);
9310
b0f9ab5a185b Devirtualize invoke before handing it to the macro node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9238
diff changeset
981 replaceInvokeCallTarget(invoke, graph, kind, target);
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
982 }
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
983
9436
ae815a4c112a Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9434
diff changeset
984 private static AbstractBeginNode createUnknownTypeSuccessor(StructuredGraph graph) {
ae815a4c112a Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9434
diff changeset
985 return AbstractBeginNode.begin(graph.add(new DeoptimizeNode(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.TypeCheckedInliningViolated)));
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
986 }
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
987
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
988 @Override
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
989 public String toString() {
5019
836e4fce33ab changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5005
diff changeset
990 StringBuilder builder = new StringBuilder(shouldFallbackToInvoke() ? "megamorphic" : "polymorphic");
7213
ceb8c5b29419 print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7098
diff changeset
991 builder.append(", ");
ceb8c5b29419 print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7098
diff changeset
992 builder.append(concretes.size());
ceb8c5b29419 print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7098
diff changeset
993 builder.append(" methods [ ");
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
994 for (int i = 0; i < concretes.size(); i++) {
5719
429accae15aa moved some methods from CodeUtil to MetaUtil
Doug Simon <doug.simon@oracle.com>
parents: 5718
diff changeset
995 builder.append(MetaUtil.format(" %H.%n(%p):%r", concretes.get(i)));
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
996 }
7213
ceb8c5b29419 print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7098
diff changeset
997 builder.append(" ], ");
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
998 builder.append(ptypes.size());
7213
ceb8c5b29419 print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7098
diff changeset
999 builder.append(" type checks [ ");
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1000 for (int i = 0; i < ptypes.size(); i++) {
7213
ceb8c5b29419 print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7098
diff changeset
1001 builder.append(" ");
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1002 builder.append(ptypes.get(i).getType().getName());
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1003 builder.append(ptypes.get(i).getProbability());
7213
ceb8c5b29419 print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7098
diff changeset
1004 }
ceb8c5b29419 print more details when -XX:+PrintDeoptimizationDetails is enabled
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7098
diff changeset
1005 builder.append(" ]");
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
1006 return builder.toString();
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
1007 }
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
1008 }
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
1009
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1010 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
1011 * Represents an inlining opportunity where the current class hierarchy leads to a monomorphic
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
1012 * target method, but for which an assumption has to be registered because of non-final classes.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1013 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1014 private static class AssumptionInlineInfo extends ExactInlineInfo {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
1015
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1016 private final Assumption takenAssumption;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1017
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
1018 public AssumptionInlineInfo(Invoke invoke, ResolvedJavaMethod concrete, Assumption takenAssumption) {
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
1019 super(invoke, concrete);
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1020 this.takenAssumption = takenAssumption;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1021 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1022
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1023 @Override
12054
bba234a1670e grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12052
diff changeset
1024 public void inline(Providers providers, Assumptions assumptions) {
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1025 assumptions.record(takenAssumption);
12054
bba234a1670e grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12052
diff changeset
1026 super.inline(providers, assumptions);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1027 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1028
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1029 @Override
11959
23ccaa863eda made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11878
diff changeset
1030 public void tryToDevirtualizeInvoke(MetaAccessProvider metaAccess, Assumptions assumptions) {
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
1031 assumptions.record(takenAssumption);
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
1032 replaceInvokeCallTarget(invoke, graph(), InvokeKind.Special, concrete);
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
1033 }
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
1034
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
1035 @Override
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1036 public String toString() {
5719
429accae15aa moved some methods from CodeUtil to MetaUtil
Doug Simon <doug.simon@oracle.com>
parents: 5718
diff changeset
1037 return "assumption " + MetaUtil.format("%H.%n(%p):%r", concrete);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1038 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1039 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1040
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1041 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1042 * Determines if inlining is possible at the given invoke node.
14865
ae7cbf13e765 correct guarding of Debug.logv in InliningUtil
Erik Eckstein <erik.eckstein@oracle.com>
parents: 14850
diff changeset
1043 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1044 * @param invoke the invoke that should be inlined
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1045 * @return an instance of InlineInfo, or null if no inlining is possible at the given invoke
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1046 */
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
1047 public static InlineInfo getInlineInfo(InliningData data, Invoke invoke, int maxNumberOfMethods, Replacements replacements, Assumptions assumptions, OptimisticOptimizations optimisticOpts) {
5127
7b2efb5ff2ea better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5114
diff changeset
1048 if (!checkInvokeConditions(invoke)) {
7b2efb5ff2ea better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5114
diff changeset
1049 return null;
7b2efb5ff2ea better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5114
diff changeset
1050 }
9147
07f05f2a8149 Remove methodCallTarget() method from the Invoke interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9089
diff changeset
1051 MethodCallTargetNode callTarget = (MethodCallTargetNode) invoke.callTarget();
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1052 ResolvedJavaMethod targetMethod = callTarget.targetMethod();
5127
7b2efb5ff2ea better inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5114
diff changeset
1053
4571
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4564
diff changeset
1054 if (callTarget.invokeKind() == InvokeKind.Special || targetMethod.canBeStaticallyBound()) {
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
1055 return getExactInlineInfo(data, invoke, replacements, optimisticOpts, targetMethod);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1056 }
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1057
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1058 assert callTarget.invokeKind() == InvokeKind.Virtual || callTarget.invokeKind() == InvokeKind.Interface;
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1059
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1060 ResolvedJavaType holder = targetMethod.getDeclaringClass();
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11258
diff changeset
1061 if (!(callTarget.receiver().stamp() instanceof ObjectStamp)) {
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11258
diff changeset
1062 return null;
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11258
diff changeset
1063 }
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11258
diff changeset
1064 ObjectStamp receiverStamp = (ObjectStamp) callTarget.receiver().stamp();
10637
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
1065 if (receiverStamp.alwaysNull()) {
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
1066 // Don't inline if receiver is known to be null
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
1067 return null;
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
1068 }
5443
141817e206d4 changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5426
diff changeset
1069 if (receiverStamp.type() != null) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
1070 // the invoke target might be more specific than the holder (happens after inlining:
13614
0774f3303c2e rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 13554
diff changeset
1071 // parameters lose their declared type...)
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1072 ResolvedJavaType receiverType = receiverStamp.type();
7097
6644cecbd3a7 Replace ResolvedJavaType.isAssignableTo with isAssignableFrom to be consistent with java.lang.Class
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7079
diff changeset
1073 if (receiverType != null && holder.isAssignableFrom(receiverType)) {
5443
141817e206d4 changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5426
diff changeset
1074 holder = receiverType;
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1075 if (receiverStamp.isExactType()) {
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1076 assert targetMethod.getDeclaringClass().isAssignableFrom(holder) : holder + " subtype of " + targetMethod.getDeclaringClass() + " for " + targetMethod;
9837
59d799c965c9 Allow ResolvedJavaType.resolveMethod to return null
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9722
diff changeset
1077 ResolvedJavaMethod resolvedMethod = holder.resolveMethod(targetMethod);
59d799c965c9 Allow ResolvedJavaType.resolveMethod to return null
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9722
diff changeset
1078 if (resolvedMethod != null) {
59d799c965c9 Allow ResolvedJavaType.resolveMethod to return null
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9722
diff changeset
1079 return getExactInlineInfo(data, invoke, replacements, optimisticOpts, resolvedMethod);
59d799c965c9 Allow ResolvedJavaType.resolveMethod to return null
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9722
diff changeset
1080 }
4457
5acf4a974e4a fixed framestate for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4456
diff changeset
1081 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1082 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1083 }
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4249
diff changeset
1084
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1085 if (holder.isArray()) {
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1086 // arrays can be treated as Objects
9837
59d799c965c9 Allow ResolvedJavaType.resolveMethod to return null
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9722
diff changeset
1087 ResolvedJavaMethod resolvedMethod = holder.resolveMethod(targetMethod);
59d799c965c9 Allow ResolvedJavaType.resolveMethod to return null
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9722
diff changeset
1088 if (resolvedMethod != null) {
59d799c965c9 Allow ResolvedJavaType.resolveMethod to return null
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9722
diff changeset
1089 return getExactInlineInfo(data, invoke, replacements, optimisticOpts, resolvedMethod);
59d799c965c9 Allow ResolvedJavaType.resolveMethod to return null
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9722
diff changeset
1090 }
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1091 }
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1092
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1093 if (assumptions.useOptimisticAssumptions()) {
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1094 ResolvedJavaType uniqueSubtype = holder.findUniqueConcreteSubtype();
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1095 if (uniqueSubtype != null) {
9837
59d799c965c9 Allow ResolvedJavaType.resolveMethod to return null
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9722
diff changeset
1096 ResolvedJavaMethod resolvedMethod = uniqueSubtype.resolveMethod(targetMethod);
59d799c965c9 Allow ResolvedJavaType.resolveMethod to return null
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9722
diff changeset
1097 if (resolvedMethod != null) {
59d799c965c9 Allow ResolvedJavaType.resolveMethod to return null
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9722
diff changeset
1098 return getAssumptionInlineInfo(data, invoke, replacements, optimisticOpts, resolvedMethod, new Assumptions.ConcreteSubtype(holder, uniqueSubtype));
59d799c965c9 Allow ResolvedJavaType.resolveMethod to return null
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9722
diff changeset
1099 }
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1100 }
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1101
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1102 ResolvedJavaMethod concrete = holder.findUniqueConcreteMethod(targetMethod);
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1103 if (concrete != null) {
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
1104 return getAssumptionInlineInfo(data, invoke, replacements, optimisticOpts, concrete, new Assumptions.ConcreteMethod(targetMethod, holder, concrete));
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1105 }
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1106 }
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1107
4459
d389f4b5bdd6 fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4458
diff changeset
1108 // type check based inlining
9704
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9701 9610
diff changeset
1109 return getTypeCheckedInlineInfo(data, invoke, maxNumberOfMethods, replacements, targetMethod, optimisticOpts);
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1110 }
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1111
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
1112 private static InlineInfo getAssumptionInlineInfo(InliningData data, Invoke invoke, Replacements replacements, OptimisticOptimizations optimisticOpts, ResolvedJavaMethod concrete,
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
1113 Assumption takenAssumption) {
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1114 assert !Modifier.isAbstract(concrete.getModifiers());
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
1115 if (!checkTargetConditions(data, replacements, invoke, concrete, optimisticOpts)) {
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1116 return null;
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1117 }
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
1118 return new AssumptionInlineInfo(invoke, concrete, takenAssumption);
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1119 }
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1120
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
1121 private static InlineInfo getExactInlineInfo(InliningData data, Invoke invoke, Replacements replacements, OptimisticOptimizations optimisticOpts, ResolvedJavaMethod targetMethod) {
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1122 assert !Modifier.isAbstract(targetMethod.getModifiers());
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
1123 if (!checkTargetConditions(data, replacements, invoke, targetMethod, optimisticOpts)) {
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1124 return null;
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7221
diff changeset
1125 }
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
1126 return new ExactInlineInfo(invoke, targetMethod);
5109
6766253384bf more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5105
diff changeset
1127 }
6766253384bf more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5105
diff changeset
1128
9705
de7319e48e48 Temporary fixes for the merge.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9704
diff changeset
1129 private static InlineInfo getTypeCheckedInlineInfo(InliningData data, Invoke invoke, int maxNumberOfMethods, Replacements replacements, ResolvedJavaMethod targetMethod,
de7319e48e48 Temporary fixes for the merge.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9704
diff changeset
1130 OptimisticOptimizations optimisticOpts) {
de7319e48e48 Temporary fixes for the merge.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9704
diff changeset
1131 JavaTypeProfile typeProfile;
9389
708aea0e5a25 Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9380
diff changeset
1132 ValueNode receiver = invoke.callTarget().arguments().get(0);
708aea0e5a25 Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9380
diff changeset
1133 if (receiver instanceof TypeProfileProxyNode) {
708aea0e5a25 Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9380
diff changeset
1134 TypeProfileProxyNode typeProfileProxyNode = (TypeProfileProxyNode) receiver;
708aea0e5a25 Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9380
diff changeset
1135 typeProfile = typeProfileProxyNode.getProfile();
708aea0e5a25 Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9380
diff changeset
1136 } else {
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
1137 return logNotInlinedMethodAndReturnNull(invoke, data.inliningDepth(), targetMethod, "no type profile exists");
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1138 }
4456
f4c82dd4619e inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4455
diff changeset
1139
9389
708aea0e5a25 Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9380
diff changeset
1140 ProfiledType[] ptypes = typeProfile.getTypes();
708aea0e5a25 Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9380
diff changeset
1141 if (ptypes == null || ptypes.length <= 0) {
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
1142 return logNotInlinedMethodAndReturnNull(invoke, data.inliningDepth(), targetMethod, "no types in profile");
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1143 }
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
1144
9389
708aea0e5a25 Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9380
diff changeset
1145 double notRecordedTypeProbability = typeProfile.getNotRecordedProbability();
708aea0e5a25 Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9380
diff changeset
1146 if (ptypes.length == 1 && notRecordedTypeProbability == 0) {
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1147 if (!optimisticOpts.inlineMonomorphicCalls()) {
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
1148 return logNotInlinedMethodAndReturnNull(invoke, data.inliningDepth(), targetMethod, "inlining monomorphic calls is disabled");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1149 }
4459
d389f4b5bdd6 fixed typecheck branch probability
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4458
diff changeset
1150
9389
708aea0e5a25 Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9380
diff changeset
1151 ResolvedJavaType type = ptypes[0].getType();
13196
e343d4623e47 weakened assertion around type profiles to allow array types (GRAAL-618)
Doug Simon <doug.simon@oracle.com>
parents: 13166
diff changeset
1152 assert type.isArray() || !isAbstract(type.getModifiers());
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1153 ResolvedJavaMethod concrete = type.resolveMethod(targetMethod);
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
1154 if (!checkTargetConditions(data, replacements, invoke, concrete, optimisticOpts)) {
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1155 return null;
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1156 }
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7392
diff changeset
1157 return new TypeGuardInlineInfo(invoke, concrete, type);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1158 } else {
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1159 invoke.setPolymorphic(true);
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1160
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1161 if (!optimisticOpts.inlinePolymorphicCalls() && notRecordedTypeProbability == 0) {
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
1162 return logNotInlinedMethodAndReturnNull(invoke, data.inliningDepth(), targetMethod, "inlining polymorphic calls is disabled (%d types)", ptypes.length);
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1163 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1164 if (!optimisticOpts.inlineMegamorphicCalls() && notRecordedTypeProbability > 0) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
1165 // due to filtering impossible types, notRecordedTypeProbability can be > 0 although
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
1166 // the number of types is lower than what can be recorded in a type profile
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
1167 return logNotInlinedMethodAndReturnNull(invoke, data.inliningDepth(), targetMethod, "inlining megamorphic calls is disabled (%d types, %f %% not recorded types)", ptypes.length,
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
1168 notRecordedTypeProbability * 100);
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1169 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1170
9392
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1171 // Find unique methods and their probabilities.
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1172 ArrayList<ResolvedJavaMethod> concreteMethods = new ArrayList<>();
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1173 ArrayList<Double> concreteMethodsProbabilities = new ArrayList<>();
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1174 for (int i = 0; i < ptypes.length; i++) {
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1175 ResolvedJavaMethod concrete = ptypes[i].getType().resolveMethod(targetMethod);
9837
59d799c965c9 Allow ResolvedJavaType.resolveMethod to return null
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9722
diff changeset
1176 if (concrete == null) {
59d799c965c9 Allow ResolvedJavaType.resolveMethod to return null
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9722
diff changeset
1177 return logNotInlinedMethodAndReturnNull(invoke, data.inliningDepth(), targetMethod, "could not resolve method");
59d799c965c9 Allow ResolvedJavaType.resolveMethod to return null
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9722
diff changeset
1178 }
9392
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1179 int index = concreteMethods.indexOf(concrete);
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1180 double curProbability = ptypes[i].getProbability();
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1181 if (index < 0) {
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1182 index = concreteMethods.size();
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1183 concreteMethods.add(concrete);
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1184 concreteMethodsProbabilities.add(curProbability);
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1185 } else {
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1186 concreteMethodsProbabilities.set(index, concreteMethodsProbabilities.get(index) + curProbability);
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1187 }
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1188 }
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1189
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
1190 if (concreteMethods.size() > maxNumberOfMethods) {
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
1191 return logNotInlinedMethodAndReturnNull(invoke, data.inliningDepth(), targetMethod, "polymorphic call with more than %d target methods", maxNumberOfMethods);
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
1192 }
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
1193
9392
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1194 // Clear methods that fall below the threshold.
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1195 if (notRecordedTypeProbability > 0) {
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1196 ArrayList<ResolvedJavaMethod> newConcreteMethods = new ArrayList<>();
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1197 ArrayList<Double> newConcreteMethodsProbabilities = new ArrayList<>();
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1198 for (int i = 0; i < concreteMethods.size(); ++i) {
9966
4158612eca60 GraalOptions: use static import
Bernhard Urban <bernhard.urban@jku.at>
parents: 9961
diff changeset
1199 if (concreteMethodsProbabilities.get(i) >= MegamorphicInliningMinMethodProbability.getValue()) {
9392
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1200 newConcreteMethods.add(concreteMethods.get(i));
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1201 newConcreteMethodsProbabilities.add(concreteMethodsProbabilities.get(i));
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1202 }
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1203 }
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1204
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1205 if (newConcreteMethods.size() == 0) {
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1206 // No method left that is worth inlining.
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
1207 return logNotInlinedMethodAndReturnNull(invoke, data.inliningDepth(), targetMethod, "no methods remaining after filtering less frequent methods (%d methods previously)",
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
1208 concreteMethods.size());
9392
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1209 }
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1210
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1211 concreteMethods = newConcreteMethods;
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1212 concreteMethodsProbabilities = newConcreteMethodsProbabilities;
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1213 }
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1214
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1215 // Clean out types whose methods are no longer available.
9389
708aea0e5a25 Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9380
diff changeset
1216 ArrayList<ProfiledType> usedTypes = new ArrayList<>();
9392
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1217 ArrayList<Integer> typesToConcretes = new ArrayList<>();
9389
708aea0e5a25 Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9380
diff changeset
1218 for (ProfiledType type : ptypes) {
9392
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1219 ResolvedJavaMethod concrete = type.getType().resolveMethod(targetMethod);
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1220 int index = concreteMethods.indexOf(concrete);
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1221 if (index == -1) {
9389
708aea0e5a25 Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9380
diff changeset
1222 notRecordedTypeProbability += type.getProbability();
708aea0e5a25 Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9380
diff changeset
1223 } else {
13196
e343d4623e47 weakened assertion around type profiles to allow array types (GRAAL-618)
Doug Simon <doug.simon@oracle.com>
parents: 13166
diff changeset
1224 assert type.getType().isArray() || !isAbstract(type.getType().getModifiers()) : type + " " + concrete;
9389
708aea0e5a25 Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9380
diff changeset
1225 usedTypes.add(type);
9392
5a74cbafe5b9 Adjustment to the megamorphic inlining strategy such that it focuses on concrete methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9389
diff changeset
1226 typesToConcretes.add(index);
9374
8649dbda7d25 New experiment with megamorphic inlining.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9329
diff changeset
1227 }
9389
708aea0e5a25 Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9380
diff changeset
1228 }
9374
8649dbda7d25 New experiment with megamorphic inlining.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9329
diff changeset
1229
9389
708aea0e5a25 Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9380
diff changeset
1230 if (usedTypes.size() == 0) {
708aea0e5a25 Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9380
diff changeset
1231 // No type left that is worth checking for.
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
1232 return logNotInlinedMethodAndReturnNull(invoke, data.inliningDepth(), targetMethod, "no types remaining after filtering less frequent types (%d types previously)", ptypes.length);
9374
8649dbda7d25 New experiment with megamorphic inlining.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9329
diff changeset
1233 }
8649dbda7d25 New experiment with megamorphic inlining.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9329
diff changeset
1234
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
1235 for (ResolvedJavaMethod concrete : concreteMethods) {
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
1236 if (!checkTargetConditions(data, replacements, invoke, concrete, optimisticOpts)) {
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
1237 return logNotInlinedMethodAndReturnNull(invoke, data.inliningDepth(), targetMethod, "it is a polymorphic method call and at least one invoked method cannot be inlined");
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1238 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1239 }
9380
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9379
diff changeset
1240 return new MultiTypeGuardInlineInfo(invoke, concreteMethods, concreteMethodsProbabilities, usedTypes, typesToConcretes, notRecordedTypeProbability);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1241 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1242 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1243
10706
8d961f93725c Use GuardedValueNode in the inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10692
diff changeset
1244 private static GuardedValueNode createAnchoredReceiver(StructuredGraph graph, GuardingNode anchor, ResolvedJavaType commonType, ValueNode receiver, boolean exact) {
10041
595f1f253ef4 Use createAnchoredReceiver to create the invokes's receiver check before inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10040
diff changeset
1245 return createAnchoredReceiver(graph, anchor, receiver, exact ? StampFactory.exactNonNull(commonType) : StampFactory.declaredNonNull(commonType));
595f1f253ef4 Use createAnchoredReceiver to create the invokes's receiver check before inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10040
diff changeset
1246 }
595f1f253ef4 Use createAnchoredReceiver to create the invokes's receiver check before inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10040
diff changeset
1247
10706
8d961f93725c Use GuardedValueNode in the inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10692
diff changeset
1248 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
1249 // to avoid that floating reads on receiver fields float above the type check
10706
8d961f93725c Use GuardedValueNode in the inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10692
diff changeset
1250 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
1251 }
495a81cd6969 avoid code generation for typechecks that are only used for anchoring
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4635
diff changeset
1252
9234
b9cf7d0b598e removal of FixedNode.probability (draft)
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9147
diff changeset
1253 // TODO (chaeubl): cleanup this method
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1254 private static boolean checkInvokeConditions(Invoke invoke) {
9089
5ab06146e985 Rename "node()" methods in interfaces to "asNode"
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9004
diff changeset
1255 if (invoke.predecessor() == null || !invoke.asNode().isAlive()) {
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
1256 return logNotInlinedMethod(invoke, "the invoke is dead code");
7391
36dafe48bc38 added relevance-based inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7388
diff changeset
1257 } else if (!(invoke.callTarget() instanceof MethodCallTargetNode)) {
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
1258 return logNotInlinedMethod(invoke, "the invoke has already been lowered, or has been created as a low-level node");
9147
07f05f2a8149 Remove methodCallTarget() method from the Invoke interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9089
diff changeset
1259 } else if (((MethodCallTargetNode) invoke.callTarget()).targetMethod() == null) {
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
1260 return logNotInlinedMethod(invoke, "target method is null");
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1261 } else if (invoke.stateAfter() == null) {
9234
b9cf7d0b598e removal of FixedNode.probability (draft)
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9147
diff changeset
1262 // TODO (chaeubl): why should an invoke not have a state after?
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
1263 return logNotInlinedMethod(invoke, "the invoke has no after state");
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1264 } else if (!invoke.useForInlining()) {
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
1265 return logNotInlinedMethod(invoke, "the invoke is marked to be not used for inlining");
9147
07f05f2a8149 Remove methodCallTarget() method from the Invoke interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9089
diff changeset
1266 } else if (((MethodCallTargetNode) invoke.callTarget()).receiver() != null && ((MethodCallTargetNode) invoke.callTarget()).receiver().isConstant() &&
07f05f2a8149 Remove methodCallTarget() method from the Invoke interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9089
diff changeset
1267 ((MethodCallTargetNode) invoke.callTarget()).receiver().asConstant().isNull()) {
9701
e538498d6eae some refactorings and cleanups for the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9699
diff changeset
1268 return logNotInlinedMethod(invoke, "receiver is null");
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1269 } else {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1270 return true;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1271 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1272 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1273
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9310
diff changeset
1274 private static boolean checkTargetConditions(InliningData data, Replacements replacements, Invoke invoke, ResolvedJavaMethod method, OptimisticOptimizations optimisticOpts) {
4530
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4529
diff changeset
1275 if (method == null) {
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
1276 return logNotInlinedMethodAndReturnFalse(invoke, data.inliningDepth(), method, "the method is not resolved");
9966
4158612eca60 GraalOptions: use static import
Bernhard Urban <bernhard.urban@jku.at>
parents: 9961
diff changeset
1277 } else if (Modifier.isNative(method.getModifiers()) && (!Intrinsify.getValue() || !InliningUtil.canIntrinsify(replacements, method))) {
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
1278 return logNotInlinedMethodAndReturnFalse(invoke, data.inliningDepth(), method, "it is a non-intrinsic native method");
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1279 } else if (Modifier.isAbstract(method.getModifiers())) {
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
1280 return logNotInlinedMethodAndReturnFalse(invoke, data.inliningDepth(), method, "it is an abstract method");
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1281 } else if (!method.getDeclaringClass().isInitialized()) {
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
1282 return logNotInlinedMethodAndReturnFalse(invoke, data.inliningDepth(), method, "the method's class is not initialized");
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1283 } else if (!method.canBeInlined()) {
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
1284 return logNotInlinedMethodAndReturnFalse(invoke, data.inliningDepth(), method, "it is marked non-inlinable");
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9837
diff changeset
1285 } else if (data.countRecursiveInlining(method) > MaximumRecursiveInlining.getValue()) {
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
1286 return logNotInlinedMethodAndReturnFalse(invoke, data.inliningDepth(), method, "it exceeds the maximum recursive inlining depth");
13217
210f58e992a1 Use separate method profile for OSR compilations.
Roland Schatz <roland.schatz@oracle.com>
parents: 13197
diff changeset
1287 } else if (new OptimisticOptimizations(method.getProfilingInfo()).lessOptimisticThan(optimisticOpts)) {
9722
b5dd7e3c8c80 Bugfixes for the inlining phase and for -XX:+PrintInlining.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9711
diff changeset
1288 return logNotInlinedMethodAndReturnFalse(invoke, data.inliningDepth(), method, "the callee uses less optimistic optimizations than caller");
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1289 } else {
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1290 return true;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1291 }
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1292 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1293
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
1294 static MonitorExitNode findPrecedingMonitorExit(UnwindNode unwind) {
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
1295 Node pred = unwind.predecessor();
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
1296 while (pred != 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
1297 if (pred instanceof MonitorExitNode) {
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
1298 return (MonitorExitNode) pred;
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
1299 }
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
1300 pred = pred.predecessor();
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
1301 }
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
1302 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
1303 }
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
1304
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1305 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1306 * Performs an actual inlining, thereby replacing the given invoke with the given inlineGraph.
14865
ae7cbf13e765 correct guarding of Debug.logv in InliningUtil
Erik Eckstein <erik.eckstein@oracle.com>
parents: 14850
diff changeset
1307 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1308 * @param invoke the invoke that will be replaced
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1309 * @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
1310 * @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
1311 * false if no such check is required
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1312 */
7309
75c18356504d Added capability to return the map of dupblicates when inlining a graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7257
diff changeset
1313 public static Map<Node, Node> inline(Invoke invoke, StructuredGraph inlineGraph, boolean receiverNullCheck) {
11669
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11657
diff changeset
1314 final NodeInputList<ValueNode> parameters = invoke.callTarget().arguments();
13692
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1315 FixedNode invokeNode = invoke.asNode();
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1316 StructuredGraph graph = invokeNode.graph();
13285
54248131f787 InliningPhase asserts correct order on the garph stages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13217
diff changeset
1317 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
1318 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
1319
14633
da2431cc1506 Rename ValueNode kind() to getKind().
Josef Eisl <josef.eisl@jku.at>
parents: 14558
diff changeset
1320 Kind returnKind = invokeNode.getKind();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1321
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1322 FrameState stateAfter = invoke.stateAfter();
9672
67804a97c1ce allow inlining of invokes with a null stateAfter
Doug Simon <doug.simon@oracle.com>
parents: 9610
diff changeset
1323 assert stateAfter == null || stateAfter.isAlive();
10637
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
1324 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
1325 nonNullReceiver(invoke);
9861
2d5c0f7ce7a1 Add a PiNode for the null-checked receiver during inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9837
diff changeset
1326 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1327
11669
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11657
diff changeset
1328 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
1329 ArrayList<ReturnNode> returnNodes = new ArrayList<>(4);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1330 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
1331 final StartNode entryPointNode = inlineGraph.start();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1332 FixedNode firstCFGNode = entryPointNode.next();
11712
0d16339188ef Improvements to the Truffle cache.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11710
diff changeset
1333 if (firstCFGNode == null) {
0d16339188ef Improvements to the Truffle cache.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11710
diff changeset
1334 throw new IllegalStateException("Inlined graph is in invalid state");
0d16339188ef Improvements to the Truffle cache.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11710
diff changeset
1335 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1336 for (Node node : inlineGraph.getNodes()) {
13614
0774f3303c2e rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 13554
diff changeset
1337 if (node == entryPointNode || node == entryPointNode.stateAfter() || node instanceof ParameterNode) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1338 // Do nothing.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1339 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1340 nodes.add(node);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1341 if (node instanceof ReturnNode) {
13692
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1342 returnNodes.add((ReturnNode) node);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1343 } 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
1344 assert unwindNode == null;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1345 unwindNode = (UnwindNode) node;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1346 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1347 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1348 }
11669
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11657
diff changeset
1349
13692
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1350 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
1351 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
1352
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11657
diff changeset
1353 public Node replacement(Node node) {
13614
0774f3303c2e rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 13554
diff changeset
1354 if (node instanceof ParameterNode) {
0774f3303c2e rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 13554
diff changeset
1355 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
1356 } 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
1357 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
1358 }
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11657
diff changeset
1359 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
1360 }
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11657
diff changeset
1361 };
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1362
13692
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1363 assert invokeNode.successors().first() != null : invoke;
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1364 assert invokeNode.predecessor() != null;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1365
11675
77d9f12797c5 Use NodeMap in inlining utility when number of nodes is high.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11669
diff changeset
1366 Map<Node, Node> duplicates = graph.addDuplicates(nodes, inlineGraph, inlineGraph.getNodeCount(), localReplacement);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1367 FixedNode firstCFGNodeDuplicate = (FixedNode) duplicates.get(firstCFGNode);
13692
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1368 invokeNode.replaceAtPredecessor(firstCFGNodeDuplicate);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1369
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1370 FrameState stateAtExceptionEdge = null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1371 if (invoke instanceof InvokeWithExceptionNode) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1372 InvokeWithExceptionNode invokeWithException = ((InvokeWithExceptionNode) invoke);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1373 if (unwindNode != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1374 assert unwindNode.predecessor() != null;
4411
cd2b68ef8e23 cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4312
diff changeset
1375 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
1376 ExceptionObjectNode obj = (ExceptionObjectNode) invokeWithException.exceptionEdge();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1377 stateAtExceptionEdge = obj.stateAfter();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1378 UnwindNode unwindDuplicate = (UnwindNode) duplicates.get(unwindNode);
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4454
diff changeset
1379 obj.replaceAtUsages(unwindDuplicate.exception());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1380 unwindDuplicate.clearInputs();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1381 Node n = obj.next();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1382 obj.setNext(null);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1383 unwindDuplicate.replaceAndDelete(n);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1384 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1385 invokeWithException.killExceptionEdge();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1386 }
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
1387
39e9ec0cf310 Inlining: remove killing begin node in non-exceptional path of InvokeWithException after inlining
Bernhard Urban <bernhard.urban@jku.at>
parents: 11839
diff changeset
1388 // get rid of memory kill
39e9ec0cf310 Inlining: remove killing begin node in non-exceptional path of InvokeWithException after inlining
Bernhard Urban <bernhard.urban@jku.at>
parents: 11839
diff changeset
1389 AbstractBeginNode begin = invokeWithException.next();
39e9ec0cf310 Inlining: remove killing begin node in non-exceptional path of InvokeWithException after inlining
Bernhard Urban <bernhard.urban@jku.at>
parents: 11839
diff changeset
1390 if (begin instanceof KillingBeginNode) {
13502
89a9d3f5bc17 Bugfix in inlining
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13378
diff changeset
1391 BeginNode newBegin = new BeginNode();
89a9d3f5bc17 Bugfix in inlining
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13378
diff changeset
1392 graph.addAfterFixed(begin, graph.add(newBegin));
89a9d3f5bc17 Bugfix in inlining
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13378
diff changeset
1393 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
1394 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
1395 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1396 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1397 if (unwindNode != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1398 UnwindNode unwindDuplicate = (UnwindNode) duplicates.get(unwindNode);
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
1399 MonitorExitNode monitorExit = findPrecedingMonitorExit(unwindDuplicate);
7660
0b646334c5f7 keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents: 7558
diff changeset
1400 DeoptimizeNode deoptimizeNode = new DeoptimizeNode(DeoptimizationAction.InvalidateRecompile, DeoptimizationReason.NotCompiledExceptionHandler);
4339
15ec30809d0f enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents: 4312
diff changeset
1401 unwindDuplicate.replaceAndDelete(graph.add(deoptimizeNode));
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
1402 // move the deopt upwards if there is a monitor exit that tries to use the
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
1403 // "after exception" frame state
4339
15ec30809d0f enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents: 4312
diff changeset
1404 // (because there is no "after exception" frame state!)
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
1405 if (monitorExit != null) {
4339
15ec30809d0f enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents: 4312
diff changeset
1406 if (monitorExit.stateAfter() != null && monitorExit.stateAfter().bci == FrameState.AFTER_EXCEPTION_BCI) {
15ec30809d0f enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents: 4312
diff changeset
1407 FrameState monitorFrameState = monitorExit.stateAfter();
15ec30809d0f enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents: 4312
diff changeset
1408 graph.removeFixed(monitorExit);
15ec30809d0f enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents: 4312
diff changeset
1409 monitorFrameState.safeDelete();
15ec30809d0f enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents: 4312
diff changeset
1410 }
15ec30809d0f enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents: 4312
diff changeset
1411 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1412 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1413 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1414
9672
67804a97c1ce allow inlining of invokes with a null stateAfter
Doug Simon <doug.simon@oracle.com>
parents: 9610
diff changeset
1415 if (stateAfter != null) {
67804a97c1ce allow inlining of invokes with a null stateAfter
Doug Simon <doug.simon@oracle.com>
parents: 9610
diff changeset
1416 FrameState outerFrameState = null;
67804a97c1ce allow inlining of invokes with a null stateAfter
Doug Simon <doug.simon@oracle.com>
parents: 9610
diff changeset
1417 int callerLockDepth = stateAfter.nestedLockDepth();
13554
83fd2094ff66 rework of monitorenter/exit (use MonitorIdNode)
Lukas Stadler <lukas.stadler@jku.at>
parents: 13502
diff changeset
1418 for (FrameState original : inlineGraph.getNodes(FrameState.class)) {
83fd2094ff66 rework of monitorenter/exit (use MonitorIdNode)
Lukas Stadler <lukas.stadler@jku.at>
parents: 13502
diff changeset
1419 FrameState frameState = (FrameState) duplicates.get(original);
83fd2094ff66 rework of monitorenter/exit (use MonitorIdNode)
Lukas Stadler <lukas.stadler@jku.at>
parents: 13502
diff changeset
1420 if (frameState != null) {
9672
67804a97c1ce allow inlining of invokes with a null stateAfter
Doug Simon <doug.simon@oracle.com>
parents: 9610
diff changeset
1421 assert frameState.bci != FrameState.BEFORE_BCI : frameState;
67804a97c1ce allow inlining of invokes with a null stateAfter
Doug Simon <doug.simon@oracle.com>
parents: 9610
diff changeset
1422 if (frameState.bci == FrameState.AFTER_BCI) {
13692
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1423 frameState.replaceAndDelete(returnKind == Kind.Void ? stateAfter : stateAfter.duplicateModified(stateAfter.bci, stateAfter.rethrowException(), returnKind,
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1424 frameState.stackAt(0)));
9672
67804a97c1ce allow inlining of invokes with a null stateAfter
Doug Simon <doug.simon@oracle.com>
parents: 9610
diff changeset
1425 } else if (frameState.bci == FrameState.AFTER_EXCEPTION_BCI) {
67804a97c1ce allow inlining of invokes with a null stateAfter
Doug Simon <doug.simon@oracle.com>
parents: 9610
diff changeset
1426 if (frameState.isAlive()) {
67804a97c1ce allow inlining of invokes with a null stateAfter
Doug Simon <doug.simon@oracle.com>
parents: 9610
diff changeset
1427 assert stateAtExceptionEdge != null;
67804a97c1ce allow inlining of invokes with a null stateAfter
Doug Simon <doug.simon@oracle.com>
parents: 9610
diff changeset
1428 frameState.replaceAndDelete(stateAtExceptionEdge);
67804a97c1ce allow inlining of invokes with a null stateAfter
Doug Simon <doug.simon@oracle.com>
parents: 9610
diff changeset
1429 } else {
67804a97c1ce allow inlining of invokes with a null stateAfter
Doug Simon <doug.simon@oracle.com>
parents: 9610
diff changeset
1430 assert stateAtExceptionEdge == null;
67804a97c1ce allow inlining of invokes with a null stateAfter
Doug Simon <doug.simon@oracle.com>
parents: 9610
diff changeset
1431 }
4339
15ec30809d0f enable UseExceptionProbability by default and fix the InliningUtil to correctly handle FrameState.AFTER_EXCEPTION_BCI for Invokes without an exception edge
Lukas Stadler <lukas.stadler@jku.at>
parents: 4312
diff changeset
1432 } else {
9672
67804a97c1ce allow inlining of invokes with a null stateAfter
Doug Simon <doug.simon@oracle.com>
parents: 9610
diff changeset
1433 // only handle the outermost frame states
67804a97c1ce allow inlining of invokes with a null stateAfter
Doug Simon <doug.simon@oracle.com>
parents: 9610
diff changeset
1434 if (frameState.outerFrameState() == null) {
14160
fd7fcd2d2072 replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents: 13977
diff changeset
1435 assert frameState.bci == FrameState.INVALID_FRAMESTATE_BCI || frameState.method().equals(inlineGraph.method());
9672
67804a97c1ce allow inlining of invokes with a null stateAfter
Doug Simon <doug.simon@oracle.com>
parents: 9610
diff changeset
1436 if (outerFrameState == null) {
14633
da2431cc1506 Rename ValueNode kind() to getKind().
Josef Eisl <josef.eisl@jku.at>
parents: 14558
diff changeset
1437 outerFrameState = stateAfter.duplicateModified(invoke.bci(), stateAfter.rethrowException(), invokeNode.getKind());
9672
67804a97c1ce allow inlining of invokes with a null stateAfter
Doug Simon <doug.simon@oracle.com>
parents: 9610
diff changeset
1438 outerFrameState.setDuringCall(true);
67804a97c1ce allow inlining of invokes with a null stateAfter
Doug Simon <doug.simon@oracle.com>
parents: 9610
diff changeset
1439 }
67804a97c1ce allow inlining of invokes with a null stateAfter
Doug Simon <doug.simon@oracle.com>
parents: 9610
diff changeset
1440 frameState.setOuterFrameState(outerFrameState);
6435
9ce24a27f035 fix for InliningUtil (dropped outer frame states while inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents: 6411
diff changeset
1441 }
4449
d84ccb0cc897 some parts for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4442
diff changeset
1442 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1443 }
13554
83fd2094ff66 rework of monitorenter/exit (use MonitorIdNode)
Lukas Stadler <lukas.stadler@jku.at>
parents: 13502
diff changeset
1444 }
83fd2094ff66 rework of monitorenter/exit (use MonitorIdNode)
Lukas Stadler <lukas.stadler@jku.at>
parents: 13502
diff changeset
1445 if (callerLockDepth != 0) {
83fd2094ff66 rework of monitorenter/exit (use MonitorIdNode)
Lukas Stadler <lukas.stadler@jku.at>
parents: 13502
diff changeset
1446 for (MonitorIdNode original : inlineGraph.getNodes(MonitorIdNode.class)) {
83fd2094ff66 rework of monitorenter/exit (use MonitorIdNode)
Lukas Stadler <lukas.stadler@jku.at>
parents: 13502
diff changeset
1447 MonitorIdNode monitor = (MonitorIdNode) duplicates.get(original);
9672
67804a97c1ce allow inlining of invokes with a null stateAfter
Doug Simon <doug.simon@oracle.com>
parents: 9610
diff changeset
1448 monitor.setLockDepth(monitor.getLockDepth() + callerLockDepth);
67804a97c1ce allow inlining of invokes with a null stateAfter
Doug Simon <doug.simon@oracle.com>
parents: 9610
diff changeset
1449 }
8586
82f6a25321b8 modeling of lock state removed from LIR and runtime specific debug info for locks moved into runtime specific classes
Doug Simon <doug.simon@oracle.com>
parents: 8469
diff changeset
1450 }
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
1451 } else {
35212baf46e5 added check that the graph inlined for an invoke with a null stateAfter contains only frame states whose bci is AFTER_BCI or INVALID_FRAMESTATE_BCI
Doug Simon <doug.simon@oracle.com>
parents: 9672
diff changeset
1452 assert checkContainsOnlyInvalidOrAfterFrameState(duplicates);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1453 }
13692
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1454 if (!returnNodes.isEmpty()) {
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1455 FixedNode n = invoke.next();
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1456 invoke.setNext(null);
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1457 if (returnNodes.size() == 1) {
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1458 ReturnNode returnNode = (ReturnNode) duplicates.get(returnNodes.get(0));
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1459 Node returnValue = returnNode.result();
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1460 invokeNode.replaceAtUsages(returnValue);
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1461 returnNode.clearInputs();
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1462 returnNode.replaceAndDelete(n);
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1463 } else {
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1464 ArrayList<ReturnNode> returnDuplicates = new ArrayList<>(returnNodes.size());
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1465 for (ReturnNode returnNode : returnNodes) {
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1466 returnDuplicates.add((ReturnNode) duplicates.get(returnNode));
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1467 }
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1468 MergeNode merge = graph.add(new MergeNode());
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1469 merge.setStateAfter(stateAfter);
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1470 ValueNode returnValue = mergeReturns(merge, returnDuplicates);
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1471 invokeNode.replaceAtUsages(returnValue);
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1472 merge.setNext(n);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1473 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1474 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1475
13692
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1476 invokeNode.replaceAtUsages(null);
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1477 GraphUtil.killCFG(invokeNode);
7309
75c18356504d Added capability to return the map of dupblicates when inlining a graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7257
diff changeset
1478
75c18356504d Added capability to return the map of dupblicates when inlining a graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7257
diff changeset
1479 return duplicates;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1480 }
4451
defa1b705f14 NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4449
diff changeset
1481
13692
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1482 public static ValueNode mergeReturns(MergeNode merge, List<? extends ReturnNode> returnNodes) {
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1483 PhiNode returnValuePhi = null;
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1484
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1485 for (ReturnNode returnNode : returnNodes) {
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1486 // create and wire up a new EndNode
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1487 EndNode endNode = merge.graph().add(new EndNode());
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1488 merge.addForwardEnd(endNode);
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1489
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1490 if (returnNode.result() != null) {
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1491 if (returnValuePhi == null) {
14558
fabf5447603e Use stamp constructor in PhiNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 14172
diff changeset
1492 returnValuePhi = merge.graph().addWithoutUnique(new PhiNode(returnNode.result().stamp().unrestricted(), merge));
13692
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1493 }
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1494 returnValuePhi.addInput(returnNode.result());
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1495 }
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1496 returnNode.clearInputs();
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1497 returnNode.replaceAndDelete(endNode);
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1498
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1499 }
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1500 return returnValuePhi;
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1501 }
c215dec9d3cf allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 13615
diff changeset
1502
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
1503 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
1504 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
1505 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
1506 FrameState frameState = (FrameState) node;
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
1507 assert frameState.bci == FrameState.AFTER_BCI || frameState.bci == FrameState.INVALID_FRAMESTATE_BCI : node.toString(Verbosity.Debugger);
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
1508 }
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
1509 }
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
1510 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
1511 }
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
1512
10637
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
1513 /**
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
1514 * 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
1515 */
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
1516 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
1517 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
1518 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
1519 StructuredGraph graph = callTarget.graph();
10637
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
1520 ValueNode firstParam = callTarget.arguments().get(0);
14633
da2431cc1506 Rename ValueNode kind() to getKind().
Josef Eisl <josef.eisl@jku.at>
parents: 14558
diff changeset
1521 if (firstParam.getKind() == Kind.Object && !ObjectStamp.isObjectNonNull(firstParam)) {
10637
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
1522 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
1523 Stamp stamp = firstParam.stamp().join(objectNonNull());
bebc9672f45e stamp for GuardingPiNode is determined by caller of constructor, not within constructor
Doug Simon <doug.simon@oracle.com>
parents: 10651
diff changeset
1524 GuardingPiNode nonNullReceiver = graph.add(new GuardingPiNode(firstParam, condition, true, NullCheckException, InvalidateReprofile, stamp));
10637
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
1525 graph.addBeforeFixed(invoke.asNode(), nonNullReceiver);
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
1526 callTarget.replaceFirstInput(firstParam, nonNullReceiver);
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
1527 return nonNullReceiver;
4451
defa1b705f14 NullCheck and IsTypeNode were in wrong order
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4449
diff changeset
1528 }
10637
ba1fbbfac0cd remove null check semantics from LoadHubNode (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents: 10041
diff changeset
1529 return firstParam;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1530 }
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1531
8636
ac4dbfecec8f passed a Replacements object to inlining utility methods that need one instead of the GraalRuntime API
Doug Simon <doug.simon@oracle.com>
parents: 8627
diff changeset
1532 public static boolean canIntrinsify(Replacements replacements, ResolvedJavaMethod target) {
ac4dbfecec8f passed a Replacements object to inlining utility methods that need one instead of the GraalRuntime API
Doug Simon <doug.simon@oracle.com>
parents: 8627
diff changeset
1533 return getIntrinsicGraph(replacements, target) != null || getMacroNodeClass(replacements, target) != null;
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1534 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1535
8636
ac4dbfecec8f passed a Replacements object to inlining utility methods that need one instead of the GraalRuntime API
Doug Simon <doug.simon@oracle.com>
parents: 8627
diff changeset
1536 public static StructuredGraph getIntrinsicGraph(Replacements replacements, ResolvedJavaMethod target) {
8627
75db7afee829 implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents: 8617
diff changeset
1537 return replacements.getMethodSubstitution(target);
7071
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1538 }
b7da4418a7c3 fixes after merge
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7070
diff changeset
1539
8636
ac4dbfecec8f passed a Replacements object to inlining utility methods that need one instead of the GraalRuntime API
Doug Simon <doug.simon@oracle.com>
parents: 8627
diff changeset
1540 public static Class<? extends FixedWithNextNode> getMacroNodeClass(Replacements replacements, ResolvedJavaMethod target) {
8627
75db7afee829 implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents: 8617
diff changeset
1541 return replacements.getMacroSubstitution(target);
7510
225002aba5a5 added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7392
diff changeset
1542 }
10644
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
1543
13601
fd522e725ee5 inliningutils: minor refactor
Bernhard Urban <bernhard.urban@jku.at>
parents: 13554
diff changeset
1544 public static FixedWithNextNode inlineMacroNode(Invoke invoke, ResolvedJavaMethod concrete, Class<? extends FixedWithNextNode> macroNodeClass) throws GraalInternalError {
fd522e725ee5 inliningutils: minor refactor
Bernhard Urban <bernhard.urban@jku.at>
parents: 13554
diff changeset
1545 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
1546 if (!concrete.equals(((MethodCallTargetNode) invoke.callTarget()).targetMethod())) {
10644
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
1547 assert ((MethodCallTargetNode) invoke.callTarget()).invokeKind() != InvokeKind.Static;
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
1548 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
1549 }
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
1550
13128
c9660efac5f6 Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12655
diff changeset
1551 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
1552
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
1553 CallTargetNode callTarget = invoke.callTarget();
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
1554 if (invoke instanceof InvokeNode) {
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
1555 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
1556 } else {
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
1557 InvokeWithExceptionNode invokeWithException = (InvokeWithExceptionNode) invoke;
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
1558 invokeWithException.killExceptionEdge();
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
1559 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
1560 }
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
1561 GraphUtil.killWithUnusedFloatingInputs(callTarget);
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
1562 return macroNode;
90a7a58bf54f Create utility method in InliningUtil for inlining macro nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10041
diff changeset
1563 }
13128
c9660efac5f6 Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12655
diff changeset
1564
c9660efac5f6 Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12655
diff changeset
1565 private static FixedWithNextNode createMacroNodeInstance(Class<? extends FixedWithNextNode> macroNodeClass, Invoke invoke) throws GraalInternalError {
c9660efac5f6 Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12655
diff changeset
1566 try {
c9660efac5f6 Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12655
diff changeset
1567 return macroNodeClass.getConstructor(Invoke.class).newInstance(invoke);
c9660efac5f6 Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12655
diff changeset
1568 } catch (ReflectiveOperationException | IllegalArgumentException | SecurityException e) {
c9660efac5f6 Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12655
diff changeset
1569 throw new GraalInternalError(e).addContext(invoke.asNode()).addContext("macroSubstitution", macroNodeClass);
c9660efac5f6 Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12655
diff changeset
1570 }
c9660efac5f6 Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12655
diff changeset
1571 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1572 }