annotate graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/InstanceOfSnippetsTemplates.java @ 9129:d0aab82a6046

removed unused code in lowering of instanceof in the context of an IfNode
author Doug Simon <doug.simon@oracle.com>
date Tue, 16 Apr 2013 12:06:30 +0200
parents 92d2bedb5dfc
children 412f6e6dad73
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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.*;
6663
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
30 import com.oracle.graal.api.meta.*;
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
31 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
32 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
33 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
34 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
35 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
36 import com.oracle.graal.nodes.util.*;
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8637
diff changeset
37 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
38 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
39 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
40
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
41 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7278
diff changeset
42 * 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
43 * 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
44 * 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
45 * 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
46 * <p>
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7278
diff changeset
47 * 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
48 * 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
49 * 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
50 * 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
51 * {@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
52 * 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
53 */
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8637
diff changeset
54 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
55
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8637
diff changeset
56 public InstanceOfSnippetsTemplates(MetaAccessProvider runtime, Replacements replacements, TargetDescription target) {
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8637
diff changeset
57 super(runtime, replacements, 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
58 }
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
59
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
60 /**
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8637
diff changeset
61 * 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
62 */
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8637
diff changeset
63 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
64
7278
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7075
diff changeset
65 public void lower(FloatingNode instanceOf, LoweringTool tool) {
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7075
diff changeset
66 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
67 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
68 int nUsages = usages.size();
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
69
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
70 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
71 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
72 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
73
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
74 InstanceOfUsageReplacer replacer = createReplacer(instanceOf, tool, nUsages, instantiation, 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
75
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
76 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
77 // 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
78 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
79 } else {
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8637
diff changeset
80 Arguments args = makeArguments(replacer, tool);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8637
diff changeset
81 template(args).instantiate(runtime, 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
82 }
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 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
86 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
87 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
88 }
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 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7278
diff changeset
92 * 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
93 * result of an instantiated instanceof snippet.
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
94 *
d0aab82a6046 removed unused code in lowering of instanceof in the context of an IfNode
Doug Simon <doug.simon@oracle.com>
parents: 9015
diff changeset
95 * @param nUsages
d0aab82a6046 removed unused code in lowering of instanceof in the context of an IfNode
Doug Simon <doug.simon@oracle.com>
parents: 9015
diff changeset
96 * @param 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
97 */
7278
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7075
diff changeset
98 protected InstanceOfUsageReplacer createReplacer(FloatingNode instanceOf, LoweringTool tool, int nUsages, 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
99 InstanceOfUsageReplacer replacer;
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
100 if (usage instanceof IfNode) {
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
101 replacer = new IfUsageReplacer(instantiation, ConstantNode.forInt(1, graph), ConstantNode.forInt(0, graph), instanceOf, (IfNode) 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
102 } else {
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
103 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
104 ConditionalNode c = (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
105 replacer = new ConditionalUsageReplacer(instantiation, c.trueValue(), c.falseValue(), instanceOf, c);
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 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
108 }
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
109
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
110 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7278
diff changeset
111 * The result of an instantiating an instanceof snippet. This enables a snippet instantiation to
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7278
diff changeset
112 * be 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
113 */
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
114 public static final class Instantiation {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7278
diff changeset
115
6663
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 PhiNode result;
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 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
118 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
119 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
120
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 * 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
123 */
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
124 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
125 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
126 }
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
127
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
128 void initialize(PhiNode phi, ValueNode t, ValueNode f) {
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
129 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
130 this.result = phi;
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
131 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
132 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
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
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
135 /**
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
136 * Gets the result of this instantiation as a condition.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7278
diff changeset
137 *
6663
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
138 * @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
139 */
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
140 CompareNode asCondition(ValueNode testValue) {
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
141 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
142 if (condition == null || condition.y() != testValue) {
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
143 // Re-use previously generated condition if the trueValue for the test is the same
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
144 condition = createCompareNode(Condition.EQ, result, testValue);
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
145 }
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
146 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
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
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 * Gets the result of the instantiation as a materialized value.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7278
diff changeset
151 *
6663
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
152 * @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
153 * @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
154 */
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
155 ValueNode asMaterialization(ValueNode t, ValueNode f) {
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
156 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
157 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
158 // 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
159 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
160 } else {
7724
ac3579b4adc9 remove MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
161 return t.graph().unique(new ConditionalNode(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
162 }
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
163 }
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 /**
7278
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7075
diff changeset
167 * 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
168 */
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
169 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
170
6663
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 final Instantiation instantiation;
7278
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7075
diff changeset
172 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
173 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
174 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
175
7278
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7075
diff changeset
176 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
177 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
178 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
179 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
180 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
181 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
182 }
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
183
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 * 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
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 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
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
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
190 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7278
diff changeset
191 * Replaces an {@link IfNode} usage of an {@link InstanceOfNode} or
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7278
diff changeset
192 * {@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
193 */
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
194 public static class IfUsageReplacer extends InstanceOfUsageReplacer {
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
195
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
196 private final IfNode usage;
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
197
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
198 public IfUsageReplacer(Instantiation instantiation, ValueNode trueValue, ValueNode falseValue, FloatingNode instanceOf, IfNode 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 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
200 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
201 }
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
202
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
203 @Override
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
204 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
205 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
206 }
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
207
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
208 @Override
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
209 public void replace(ValueNode oldNode, ValueNode newNode) {
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
210 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
211 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
212 newNode.inferStamp();
d0aab82a6046 removed unused code in lowering of instanceof in the context of an IfNode
Doug Simon <doug.simon@oracle.com>
parents: 9015
diff changeset
213 instantiation.initialize((PhiNode) newNode, trueValue, falseValue);
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 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
215 }
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
216 }
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 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7278
diff changeset
219 * Replaces a {@link ConditionalNode} usage of an {@link InstanceOfNode} or
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7278
diff changeset
220 * {@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
221 */
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
222 public static class ConditionalUsageReplacer extends InstanceOfUsageReplacer {
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
223
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
224 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
225
7278
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7075
diff changeset
226 public ConditionalUsageReplacer(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
227 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
228 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
229 }
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
230
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
231 @Override
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
232 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
233 ValueNode newValue = instantiation.asMaterialization(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
234 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
235 usage.clearInputs();
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
236 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
237 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
238 }
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 @Override
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
241 public void replace(ValueNode oldNode, ValueNode newNode) {
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
242 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
243 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
244 newNode.inferStamp();
04944369f982 refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
245 instantiation.initialize((PhiNode) newNode, 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
246 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
247 usage.clearInputs();
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 }