Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/InstanceOfSnippetsTemplates.java @ 16895:06c15e88d383
added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 18 Aug 2014 14:04:21 +0200 |
parents | e34bb128f227 |
children | 9619ba4daf4c |
rev | line source |
---|---|
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 * |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 * |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 * |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 * |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 * questions. |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
22 */ |
8415
2361bf148c06
rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents:
8413
diff
changeset
|
23 package com.oracle.graal.replacements; |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6696
diff
changeset
|
25 import static com.oracle.graal.nodes.calc.CompareNode.*; |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
26 |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
27 import java.util.*; |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
28 |
7034
89df4e71940a
More flexible handling of stamp for word type: Define a singleton Stamp instance for words that is then re-written to the target-specific primitive word stamp by the WordTypeRewriterPhase. This allows nodes to have a word stamp without any dependency on global or static state.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6950
diff
changeset
|
29 import com.oracle.graal.api.code.*; |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13611
diff
changeset
|
30 import com.oracle.graal.api.replacements.*; |
15200
97eed257999b
Move Condition to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
31 import com.oracle.graal.compiler.common.calc.*; |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
32 import com.oracle.graal.graph.*; |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
33 import com.oracle.graal.nodes.*; |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
34 import com.oracle.graal.nodes.calc.*; |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
35 import com.oracle.graal.nodes.java.*; |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
36 import com.oracle.graal.nodes.spi.*; |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
37 import com.oracle.graal.nodes.util.*; |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
38 import com.oracle.graal.phases.util.*; |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8637
diff
changeset
|
39 import com.oracle.graal.replacements.SnippetTemplate.AbstractTemplates; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8637
diff
changeset
|
40 import com.oracle.graal.replacements.SnippetTemplate.Arguments; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8637
diff
changeset
|
41 import com.oracle.graal.replacements.SnippetTemplate.UsageReplacer; |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
42 |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
43 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7278
diff
changeset
|
44 * Helper class for lowering {@link InstanceOfNode}s with snippets. The majority of the complexity |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7278
diff
changeset
|
45 * in such a lowering derives from the fact that {@link InstanceOfNode} is a floating node. A |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7278
diff
changeset
|
46 * snippet used to lower an {@link InstanceOfNode} will almost always incorporate control flow and |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7278
diff
changeset
|
47 * replacing a floating node with control flow is not trivial. |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
48 * <p> |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7278
diff
changeset
|
49 * The mechanism implemented in this class ensures that the graph for an instanceof snippet is |
8413
d9347ee39fbe
rename: SnippetsInterface -> Snippets
Doug Simon <doug.simon@oracle.com>
parents:
8178
diff
changeset
|
50 * instantiated once per {@link InstanceOfNode} being lowered. The result produced is then re-used |
d9347ee39fbe
rename: SnippetsInterface -> Snippets
Doug Simon <doug.simon@oracle.com>
parents:
8178
diff
changeset
|
51 * by all usages of the node. Additionally, if there is a single usage that is an {@link IfNode}, |
d9347ee39fbe
rename: SnippetsInterface -> Snippets
Doug Simon <doug.simon@oracle.com>
parents:
8178
diff
changeset
|
52 * the control flow in the snippet is connected directly to the true and false successors of the |
d9347ee39fbe
rename: SnippetsInterface -> Snippets
Doug Simon <doug.simon@oracle.com>
parents:
8178
diff
changeset
|
53 * {@link IfNode}. This avoids materializing the instanceof test as a boolean which is then retested |
d9347ee39fbe
rename: SnippetsInterface -> Snippets
Doug Simon <doug.simon@oracle.com>
parents:
8178
diff
changeset
|
54 * by the {@link IfNode}. |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
55 */ |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8637
diff
changeset
|
56 public abstract class InstanceOfSnippetsTemplates extends AbstractTemplates { |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
57 |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13611
diff
changeset
|
58 public InstanceOfSnippetsTemplates(Providers providers, SnippetReflectionProvider snippetReflection, TargetDescription target) { |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13611
diff
changeset
|
59 super(providers, snippetReflection, target); |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
60 } |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
61 |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
62 /** |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8637
diff
changeset
|
63 * Gets the arguments used to retrieve and instantiate an instanceof snippet template. |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
64 */ |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8637
diff
changeset
|
65 protected abstract Arguments makeArguments(InstanceOfUsageReplacer replacer, LoweringTool tool); |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
66 |
7278
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
7075
diff
changeset
|
67 public void lower(FloatingNode instanceOf, LoweringTool tool) { |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
7075
diff
changeset
|
68 assert instanceOf instanceof InstanceOfNode || instanceOf instanceof InstanceOfDynamicNode; |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
69 List<Node> usages = instanceOf.usages().snapshot(); |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
70 |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
71 Instantiation instantiation = new Instantiation(); |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
72 for (Node usage : usages) { |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
73 final StructuredGraph graph = (StructuredGraph) usage.graph(); |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
74 |
10693
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
10001
diff
changeset
|
75 InstanceOfUsageReplacer replacer = createReplacer(instanceOf, instantiation, usage, graph); |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
76 |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
77 if (instantiation.isInitialized()) { |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
78 // No need to re-instantiate the snippet - just re-use its result |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
79 replacer.replaceUsingInstantiation(); |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
80 } else { |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8637
diff
changeset
|
81 Arguments args = makeArguments(replacer, tool); |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
82 template(args).instantiate(providers.getMetaAccess(), instanceOf, replacer, tool, args); |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
83 } |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
84 } |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
85 |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
86 assert instanceOf.usages().isEmpty(); |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
87 if (!instanceOf.isDeleted()) { |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
88 GraphUtil.killWithUnusedFloatingInputs(instanceOf); |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
89 } |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
90 } |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
91 |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
92 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7278
diff
changeset
|
93 * Gets the specific replacer object used to replace the usage of an instanceof node with the |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7278
diff
changeset
|
94 * result of an instantiated instanceof snippet. |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
95 */ |
10693
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
10001
diff
changeset
|
96 protected InstanceOfUsageReplacer createReplacer(FloatingNode instanceOf, Instantiation instantiation, Node usage, final StructuredGraph graph) { |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
97 InstanceOfUsageReplacer replacer; |
13611
428403544e77
fix lowering of instanceof with ConditionAnchorNode usage
Andreas Woess <andreas.woess@jku.at>
parents:
12655
diff
changeset
|
98 if (usage instanceof IfNode || usage instanceof FixedGuardNode || usage instanceof ShortCircuitOrNode || usage instanceof GuardingPiNode || usage instanceof ConditionAnchorNode) { |
10693
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
10001
diff
changeset
|
99 replacer = new NonMaterializationUsageReplacer(instantiation, ConstantNode.forInt(1, graph), ConstantNode.forInt(0, graph), instanceOf, usage); |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
100 } else { |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
101 assert usage instanceof ConditionalNode : "unexpected usage of " + instanceOf + ": " + usage; |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
102 ConditionalNode c = (ConditionalNode) usage; |
10693
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
10001
diff
changeset
|
103 replacer = new MaterializationUsageReplacer(instantiation, c.trueValue(), c.falseValue(), instanceOf, c); |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
104 } |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
105 return replacer; |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
106 } |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
107 |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
108 /** |
10001
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9360
diff
changeset
|
109 * The result of instantiating an instanceof snippet. This enables a snippet instantiation to be |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9360
diff
changeset
|
110 * re-used which reduces compile time and produces better code. |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
111 */ |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
112 public static final class Instantiation { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7278
diff
changeset
|
113 |
10001
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9360
diff
changeset
|
114 private ValueNode result; |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
115 private CompareNode condition; |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
116 private ValueNode trueValue; |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
117 private ValueNode falseValue; |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
118 |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
119 /** |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
120 * Determines if the instantiation has occurred. |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
121 */ |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
122 boolean isInitialized() { |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
123 return result != null; |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
124 } |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
125 |
10001
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9360
diff
changeset
|
126 void initialize(ValueNode r, ValueNode t, ValueNode f) { |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
127 assert !isInitialized(); |
10001
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9360
diff
changeset
|
128 this.result = r; |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
129 this.trueValue = t; |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
130 this.falseValue = f; |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
131 } |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
132 |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
133 /** |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
134 * Gets the result of this instantiation as a condition. |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13611
diff
changeset
|
135 * |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
136 * @param testValue the returned condition is true if the result is equal to this value |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
137 */ |
10001
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9360
diff
changeset
|
138 LogicNode asCondition(ValueNode testValue) { |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
139 assert isInitialized(); |
10001
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9360
diff
changeset
|
140 if (result.isConstant()) { |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9360
diff
changeset
|
141 assert testValue.isConstant(); |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9360
diff
changeset
|
142 return LogicConstantNode.forBoolean(result.asConstant().equals(testValue.asConstant()), result.graph()); |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9360
diff
changeset
|
143 } |
16207
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16097
diff
changeset
|
144 if (condition == null || condition.getY() != testValue) { |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
145 // Re-use previously generated condition if the trueValue for the test is the same |
12655
2c4aa758ee18
made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12054
diff
changeset
|
146 condition = createCompareNode(result.graph(), Condition.EQ, result, testValue); |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
147 } |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
148 return condition; |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
149 } |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
150 |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
151 /** |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
152 * Gets the result of the instantiation as a materialized value. |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13611
diff
changeset
|
153 * |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
154 * @param t the true value for the materialization |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
155 * @param f the false value for the materialization |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
156 */ |
12655
2c4aa758ee18
made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12054
diff
changeset
|
157 ValueNode asMaterialization(StructuredGraph graph, ValueNode t, ValueNode f) { |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
158 assert isInitialized(); |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
159 if (t == this.trueValue && f == this.falseValue) { |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
160 // Can simply use the phi result if the same materialized values are expected. |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
161 return result; |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
162 } else { |
16895
06c15e88d383
added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents:
16232
diff
changeset
|
163 return graph.unique(ConditionalNode.create(asCondition(trueValue), t, f)); |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
164 } |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
165 } |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
166 } |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
167 |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
168 /** |
7278
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
7075
diff
changeset
|
169 * Replaces a usage of an {@link InstanceOfNode} or {@link InstanceOfDynamicNode}. |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
170 */ |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
171 public abstract static class InstanceOfUsageReplacer implements UsageReplacer { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7278
diff
changeset
|
172 |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
173 public final Instantiation instantiation; |
7278
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
7075
diff
changeset
|
174 public final FloatingNode instanceOf; |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
175 public final ValueNode trueValue; |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
176 public final ValueNode falseValue; |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
177 |
7278
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
7075
diff
changeset
|
178 public InstanceOfUsageReplacer(Instantiation instantiation, FloatingNode instanceOf, ValueNode trueValue, ValueNode falseValue) { |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
7075
diff
changeset
|
179 assert instanceOf instanceof InstanceOfNode || instanceOf instanceof InstanceOfDynamicNode; |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
180 this.instantiation = instantiation; |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
181 this.instanceOf = instanceOf; |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
182 this.trueValue = trueValue; |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
183 this.falseValue = falseValue; |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
184 } |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
185 |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
186 /** |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
187 * Does the replacement based on a previously snippet instantiation. |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
188 */ |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
189 public abstract void replaceUsingInstantiation(); |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
190 } |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
191 |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
192 /** |
10693
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
10001
diff
changeset
|
193 * Replaces the usage of an {@link InstanceOfNode} or {@link InstanceOfDynamicNode} that does |
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
10001
diff
changeset
|
194 * not materialize the result of the type test. |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
195 */ |
10693
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
10001
diff
changeset
|
196 public static class NonMaterializationUsageReplacer extends InstanceOfUsageReplacer { |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
197 |
10693
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
10001
diff
changeset
|
198 private final Node usage; |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
199 |
10693
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
10001
diff
changeset
|
200 public NonMaterializationUsageReplacer(Instantiation instantiation, ValueNode trueValue, ValueNode falseValue, FloatingNode instanceOf, Node usage) { |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
201 super(instantiation, instanceOf, trueValue, falseValue); |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
202 this.usage = usage; |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
203 } |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
204 |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
205 @Override |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
206 public void replaceUsingInstantiation() { |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
207 usage.replaceFirstInput(instanceOf, instantiation.asCondition(trueValue)); |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
208 } |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
209 |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
210 @Override |
16227
ec17c588abf9
rename: MemoryMapNode -> MemoryMap
Doug Simon <doug.simon@oracle.com>
parents:
16097
diff
changeset
|
211 public void replace(ValueNode oldNode, ValueNode newNode, MemoryMap mmap) { |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
212 assert newNode instanceof PhiNode; |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
213 assert oldNode == instanceOf; |
9129
d0aab82a6046
removed unused code in lowering of instanceof in the context of an IfNode
Doug Simon <doug.simon@oracle.com>
parents:
9015
diff
changeset
|
214 newNode.inferStamp(); |
10001
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9360
diff
changeset
|
215 instantiation.initialize(newNode, trueValue, falseValue); |
9129
d0aab82a6046
removed unused code in lowering of instanceof in the context of an IfNode
Doug Simon <doug.simon@oracle.com>
parents:
9015
diff
changeset
|
216 usage.replaceFirstInput(oldNode, instantiation.asCondition(trueValue)); |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
217 } |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
218 } |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
219 |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
220 /** |
10693
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
10001
diff
changeset
|
221 * Replaces the usage of an {@link InstanceOfNode} or {@link InstanceOfDynamicNode} that does |
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
10001
diff
changeset
|
222 * materializes the result of the type test. |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
223 */ |
10693
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
10001
diff
changeset
|
224 public static class MaterializationUsageReplacer extends InstanceOfUsageReplacer { |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
225 |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
226 public final ConditionalNode usage; |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
227 |
10693
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
10001
diff
changeset
|
228 public MaterializationUsageReplacer(Instantiation instantiation, ValueNode trueValue, ValueNode falseValue, FloatingNode instanceOf, ConditionalNode usage) { |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
229 super(instantiation, instanceOf, trueValue, falseValue); |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
230 this.usage = usage; |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
231 } |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
232 |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
233 @Override |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
234 public void replaceUsingInstantiation() { |
12655
2c4aa758ee18
made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12054
diff
changeset
|
235 ValueNode newValue = instantiation.asMaterialization(usage.graph(), trueValue, falseValue); |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
236 usage.replaceAtUsages(newValue); |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
237 assert usage.usages().isEmpty(); |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
238 GraphUtil.killWithUnusedFloatingInputs(usage); |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
239 } |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
240 |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
241 @Override |
16227
ec17c588abf9
rename: MemoryMapNode -> MemoryMap
Doug Simon <doug.simon@oracle.com>
parents:
16097
diff
changeset
|
242 public void replace(ValueNode oldNode, ValueNode newNode, MemoryMap mmap) { |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
243 assert newNode instanceof PhiNode; |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
244 assert oldNode == instanceOf; |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
245 newNode.inferStamp(); |
10001
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9360
diff
changeset
|
246 instantiation.initialize(newNode, trueValue, falseValue); |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
247 usage.replaceAtUsages(newNode); |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
248 assert usage.usages().isEmpty(); |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
249 GraphUtil.killWithUnusedFloatingInputs(usage); |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
250 } |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
251 } |
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
252 } |