Mercurial > hg > truffle
annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadHubNode.java @ 19526:8fc336a04d77
Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Fri, 20 Feb 2015 22:22:55 +0100 |
parents | 61d3cb8e1280 |
children | 3362ba500371 |
rev | line source |
---|---|
4467
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff
changeset
|
1 /* |
19396
7e2c87dae93e
Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
2 * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. |
4467
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff
changeset
|
4 * |
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff
changeset
|
8 * |
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff
changeset
|
14 * |
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff
changeset
|
18 * |
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff
changeset
|
21 * questions. |
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff
changeset
|
22 */ |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
23 package com.oracle.graal.nodes.extended; |
4467
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff
changeset
|
24 |
7220
fcae6d960acd
added more compiler intrinsics
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7066
diff
changeset
|
25 import com.oracle.graal.api.meta.*; |
15198
2c0cfbf454b5
Move LIRTypeTool and Stamp to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
14996
diff
changeset
|
26 import com.oracle.graal.compiler.common.type.*; |
19396
7e2c87dae93e
Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
27 import com.oracle.graal.graph.*; |
11881
da9db8331658
moved Canonicalizable and Simplifiable to the com.oracle.graal.graph project (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents:
11880
diff
changeset
|
28 import com.oracle.graal.graph.spi.*; |
16841
cbd42807a31f
moved NodeInfo and friends into separate com.oracle.graal.nodeinfo project so that annotation processor can be applied to the base Node class
Doug Simon <doug.simon@oracle.com>
parents:
16822
diff
changeset
|
29 import com.oracle.graal.nodeinfo.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
30 import com.oracle.graal.nodes.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
31 import com.oracle.graal.nodes.spi.*; |
4467
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff
changeset
|
32 |
6459
a938e15e3bd7
made ReadHubNode floating
Doug Simon <doug.simon@oracle.com>
parents:
5758
diff
changeset
|
33 /** |
18361
6ac7e9c85be6
Split getEncoding into two methods.
Roland Schatz <roland.schatz@oracle.com>
parents:
18187
diff
changeset
|
34 * Loads an object's hub. The object is not null-checked by this operation. |
6459
a938e15e3bd7
made ReadHubNode floating
Doug Simon <doug.simon@oracle.com>
parents:
5758
diff
changeset
|
35 */ |
16822
5d468add216f
added @NodeInfo annotations to all Node classes
Doug Simon <doug.simon@oracle.com>
parents:
16586
diff
changeset
|
36 @NodeInfo |
18998
ec0733b5a90a
Allow final modifier on node subclasses and start adding the modifier to leaf classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18845
diff
changeset
|
37 public final class LoadHubNode extends FloatingGuardedNode implements Lowerable, Canonicalizable, Virtualizable { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7394
diff
changeset
|
38 |
19526
8fc336a04d77
Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19403
diff
changeset
|
39 public static final NodeClass<LoadHubNode> TYPE = NodeClass.create(LoadHubNode.class); |
16897
f90dcdbbb75e
switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors
Doug Simon <doug.simon@oracle.com>
parents:
16895
diff
changeset
|
40 @Input ValueNode value; |
4467
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff
changeset
|
41 |
16219
24c30ecf930f
rename object() to getValue() in LoadHubNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15835
diff
changeset
|
42 public ValueNode getValue() { |
24c30ecf930f
rename object() to getValue() in LoadHubNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15835
diff
changeset
|
43 return value; |
4467
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff
changeset
|
44 } |
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff
changeset
|
45 |
18496
59ffee3765ec
LoadHubNode should always use StampProvider stamp
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18402
diff
changeset
|
46 private static Stamp hubStamp(StampProvider stampProvider, ValueNode value) { |
59ffee3765ec
LoadHubNode should always use StampProvider stamp
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18402
diff
changeset
|
47 assert value.stamp() instanceof ObjectStamp; |
59ffee3765ec
LoadHubNode should always use StampProvider stamp
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18402
diff
changeset
|
48 return stampProvider.createHubStamp(((ObjectStamp) value.stamp())); |
14996
88d77743dff3
do not implicitly set guard to null in LoadHubNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
13505
diff
changeset
|
49 } |
88d77743dff3
do not implicitly set guard to null in LoadHubNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
13505
diff
changeset
|
50 |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18496
diff
changeset
|
51 public LoadHubNode(@InjectedNodeParameter StampProvider stampProvider, ValueNode value) { |
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18496
diff
changeset
|
52 this(stampProvider, value, null); |
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18496
diff
changeset
|
53 } |
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18496
diff
changeset
|
54 |
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18496
diff
changeset
|
55 public LoadHubNode(@InjectedNodeParameter StampProvider stampProvider, ValueNode value, ValueNode guard) { |
19396
7e2c87dae93e
Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
56 super(TYPE, hubStamp(stampProvider, value), (GuardingNode) guard); |
16219
24c30ecf930f
rename object() to getValue() in LoadHubNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15835
diff
changeset
|
57 assert value != guard; |
24c30ecf930f
rename object() to getValue() in LoadHubNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15835
diff
changeset
|
58 this.value = value; |
4467
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff
changeset
|
59 } |
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff
changeset
|
60 |
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff
changeset
|
61 @Override |
11579
ae619d70bf4b
Rename LoweringType to GuardsPhase and make it an attribute of StructuredGraphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11325
diff
changeset
|
62 public void lower(LoweringTool tool) { |
18377
ed0fce2e999a
Fold klass._java_mirror._klass into klass and improve stamps from layout_helper
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18362
diff
changeset
|
63 if (tool.getLoweringStage() == LoweringTool.StandardLoweringStage.HIGH_TIER) { |
ed0fce2e999a
Fold klass._java_mirror._klass into klass and improve stamps from layout_helper
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18362
diff
changeset
|
64 return; |
ed0fce2e999a
Fold klass._java_mirror._klass into klass and improve stamps from layout_helper
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18362
diff
changeset
|
65 } |
13505
75a67ebd50e8
Introduce a LoweringStage so that lowerings can be conditional on one of the three times that lowering is performed by default
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13218
diff
changeset
|
66 tool.getLowerer().lower(this, tool); |
4467
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff
changeset
|
67 } |
5388
e4321a9bc0cb
use exactType and assumptions to canonicalize ReadHubNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
5286
diff
changeset
|
68 |
e4321a9bc0cb
use exactType and assumptions to canonicalize ReadHubNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
5286
diff
changeset
|
69 @Override |
16586
4a8f255c8c8d
LoadHubNode is not Canonicalizable.Unary (beause of the guard)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16222
diff
changeset
|
70 public ValueNode canonical(CanonicalizerTool tool) { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11881
diff
changeset
|
71 MetaAccessProvider metaAccess = tool.getMetaAccess(); |
16586
4a8f255c8c8d
LoadHubNode is not Canonicalizable.Unary (beause of the guard)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16222
diff
changeset
|
72 if (metaAccess != null && getValue().stamp() instanceof ObjectStamp) { |
17276
ffb974bef674
moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents:
16919
diff
changeset
|
73 ObjectStamp objectStamp = (ObjectStamp) getValue().stamp(); |
5388
e4321a9bc0cb
use exactType and assumptions to canonicalize ReadHubNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
5286
diff
changeset
|
74 |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5510
diff
changeset
|
75 ResolvedJavaType exactType; |
17276
ffb974bef674
moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents:
16919
diff
changeset
|
76 if (objectStamp.isExactType()) { |
ffb974bef674
moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents:
16919
diff
changeset
|
77 exactType = objectStamp.type(); |
19306
a0a760b0fb5f
pulled method evolution dependencies out of Assumptions and directly into StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents:
19250
diff
changeset
|
78 } else if (objectStamp.type() != null && graph().getAssumptions() != null) { |
17276
ffb974bef674
moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents:
16919
diff
changeset
|
79 exactType = objectStamp.type().findUniqueConcreteSubtype(); |
5473
c73882b7db10
runtime may be null in the canonicalizer (like target or assumptions)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5443
diff
changeset
|
80 if (exactType != null) { |
19250
8ab925a6f724
made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents:
18998
diff
changeset
|
81 graph().getAssumptions().recordConcreteSubtype(objectStamp.type(), exactType); |
5473
c73882b7db10
runtime may be null in the canonicalizer (like target or assumptions)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5443
diff
changeset
|
82 } |
c73882b7db10
runtime may be null in the canonicalizer (like target or assumptions)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5443
diff
changeset
|
83 } else { |
c73882b7db10
runtime may be null in the canonicalizer (like target or assumptions)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5443
diff
changeset
|
84 exactType = null; |
c73882b7db10
runtime may be null in the canonicalizer (like target or assumptions)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5443
diff
changeset
|
85 } |
c73882b7db10
runtime may be null in the canonicalizer (like target or assumptions)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5443
diff
changeset
|
86 |
5388
e4321a9bc0cb
use exactType and assumptions to canonicalize ReadHubNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
5286
diff
changeset
|
87 if (exactType != null) { |
18362
ea0fbb571466
Use pointer stamps in LoadHub and LoadMethod.
Roland Schatz <roland.schatz@oracle.com>
parents:
18361
diff
changeset
|
88 return ConstantNode.forConstant(stamp(), exactType.getObjectHub(), metaAccess); |
5388
e4321a9bc0cb
use exactType and assumptions to canonicalize ReadHubNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
5286
diff
changeset
|
89 } |
e4321a9bc0cb
use exactType and assumptions to canonicalize ReadHubNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
5286
diff
changeset
|
90 } |
e4321a9bc0cb
use exactType and assumptions to canonicalize ReadHubNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
5286
diff
changeset
|
91 return this; |
e4321a9bc0cb
use exactType and assumptions to canonicalize ReadHubNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
5286
diff
changeset
|
92 } |
6459
a938e15e3bd7
made ReadHubNode floating
Doug Simon <doug.simon@oracle.com>
parents:
5758
diff
changeset
|
93 |
6710
6db6881c1270
add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents:
6539
diff
changeset
|
94 @Override |
6db6881c1270
add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents:
6539
diff
changeset
|
95 public void virtualize(VirtualizerTool tool) { |
16219
24c30ecf930f
rename object() to getValue() in LoadHubNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15835
diff
changeset
|
96 State state = tool.getObjectState(value); |
7394
94f032472c28
changed PEA interface:
Lukas Stadler <lukas.stadler@jku.at>
parents:
7221
diff
changeset
|
97 if (state != null) { |
18362
ea0fbb571466
Use pointer stamps in LoadHub and LoadMethod.
Roland Schatz <roland.schatz@oracle.com>
parents:
18361
diff
changeset
|
98 Constant constantHub = state.getVirtualObject().type().getObjectHub(); |
ea0fbb571466
Use pointer stamps in LoadHub and LoadMethod.
Roland Schatz <roland.schatz@oracle.com>
parents:
18361
diff
changeset
|
99 tool.replaceWithValue(ConstantNode.forConstant(stamp(), constantHub, tool.getMetaAccessProvider(), graph())); |
6710
6db6881c1270
add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents:
6539
diff
changeset
|
100 } |
6db6881c1270
add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents:
6539
diff
changeset
|
101 } |
4467
ed73455e9c03
fixed endless recompiles
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff
changeset
|
102 } |