Mercurial > hg > truffle
annotate graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/LoadField.java @ 2947:e86e83c5adbc
More on lowering.
author | Thomas Wuerthinger <thomas@wuerthinger.net> |
---|---|
date | Fri, 10 Jun 2011 21:51:42 +0200 |
parents | cd4176d590e7 |
children | 0c0e407faa39 |
rev | line source |
---|---|
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
1 /* |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
2 * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
4 * |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
8 * |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
13 * accompanied this code). |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
14 * |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
18 * |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
21 * questions. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
22 */ |
2874
d90bf514d647
Renamed packages.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2872
diff
changeset
|
23 package com.oracle.max.graal.compiler.ir; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
24 |
2874
d90bf514d647
Renamed packages.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2872
diff
changeset
|
25 import com.oracle.max.graal.compiler.debug.*; |
2918
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
26 import com.oracle.max.graal.compiler.graph.*; |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
27 import com.oracle.max.graal.compiler.phases.CanonicalizerPhase.CanonicalizerOp; |
2947
e86e83c5adbc
More on lowering.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2941
diff
changeset
|
28 import com.oracle.max.graal.compiler.phases.LoweringPhase.LoweringOp; |
e86e83c5adbc
More on lowering.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2941
diff
changeset
|
29 import com.oracle.max.graal.compiler.phases.LoweringPhase.LoweringTool; |
2874
d90bf514d647
Renamed packages.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2872
diff
changeset
|
30 import com.oracle.max.graal.graph.*; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
31 import com.sun.cri.ci.*; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
32 import com.sun.cri.ri.*; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
33 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
34 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
35 * The {@code LoadField} instruction represents a read of a static or instance field. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
36 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
37 public final class LoadField extends AccessField { |
2918
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
38 private static final LoadFieldCanonicalizerOp CANONICALIZER = new LoadFieldCanonicalizerOp(); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
39 |
2595
4a4dab936c1e
new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents:
2540
diff
changeset
|
40 private static final int INPUT_COUNT = 0; |
4a4dab936c1e
new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents:
2540
diff
changeset
|
41 private static final int SUCCESSOR_COUNT = 0; |
4a4dab936c1e
new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents:
2540
diff
changeset
|
42 |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
43 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
44 * Creates a new LoadField instance. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
45 * @param object the receiver object |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
46 * @param field the compiler interface field |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
47 * @param isStatic indicates if the field is static |
2622
91d3952f7eb7
Framestate work : using stateAFter and reducting the number of nodes with framestates. Intermediate state (does not pass tests)
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2595
diff
changeset
|
48 * @param stateAfter the state after the field access |
2595
4a4dab936c1e
new node layout: AccessField
Lukas Stadler <lukas.stadler@jku.at>
parents:
2540
diff
changeset
|
49 * @param graph |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
50 * @param isLoaded indicates if the class is loaded |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
51 */ |
2709
7b7dbe19fafb
Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2673
diff
changeset
|
52 public LoadField(Value object, RiField field, Graph graph) { |
2628
569228710be8
More FrameState work
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2622
diff
changeset
|
53 super(field.kind().stackKind(), object, field, INPUT_COUNT, SUCCESSOR_COUNT, graph); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
54 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
55 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
56 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
57 * Gets the declared type of the field being accessed. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
58 * @return the declared type of the field being accessed. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
59 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
60 @Override |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
61 public RiType declaredType() { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
62 return field().type(); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
63 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
64 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
65 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
66 * Gets the exact type of the field being accessed. If the field type is |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
67 * a primitive array or an instance class and the class is loaded and final, |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
68 * then the exact type is the same as the declared type. Otherwise it is {@code null} |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
69 * @return the exact type of the field if known; {@code null} otherwise |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
70 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
71 @Override |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
72 public RiType exactType() { |
2941
cd4176d590e7
Towards lowering phase.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2918
diff
changeset
|
73 RiType declared = declaredType(); |
cd4176d590e7
Towards lowering phase.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2918
diff
changeset
|
74 return declared != null && declared.isResolved() ? declared.exactType() : null; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
75 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
76 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
77 @Override |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
78 public void accept(ValueVisitor v) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
79 v.visitLoadField(this); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
80 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
81 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
82 @Override |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
83 public void print(LogStream out) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
84 out.print(object()). |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
85 print("."). |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
86 print(field.name()). |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
87 print(" [field: "). |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
88 print(CiUtil.format("%h.%n:%t", field, false)). |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
89 print("]"); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
90 } |
2628
569228710be8
More FrameState work
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2622
diff
changeset
|
91 |
569228710be8
More FrameState work
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2622
diff
changeset
|
92 @Override |
569228710be8
More FrameState work
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2622
diff
changeset
|
93 public boolean needsStateAfter() { |
2653
7c8ad40c1f88
No need for stateAfter on volatile field loads.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2628
diff
changeset
|
94 return false; |
2628
569228710be8
More FrameState work
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2622
diff
changeset
|
95 } |
2827
bd17ac598c6e
Graph cloning, initial version (not completely working)
Lukas Stadler <lukas.stadler@jku.at>
parents:
2709
diff
changeset
|
96 |
2918
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
97 /** |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
98 * Gets a constant value to which this load can be reduced. |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
99 * |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
100 * @return {@code null} if this load cannot be reduced to a constant |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
101 */ |
2941
cd4176d590e7
Towards lowering phase.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2918
diff
changeset
|
102 private CiConstant constantValue() { |
2918
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
103 if (isStatic()) { |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
104 return field.constantValue(null); |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
105 } else if (object().isConstant()) { |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
106 return field.constantValue(object().asConstant()); |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
107 } |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
108 return null; |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
109 } |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
110 |
2827
bd17ac598c6e
Graph cloning, initial version (not completely working)
Lukas Stadler <lukas.stadler@jku.at>
parents:
2709
diff
changeset
|
111 @Override |
bd17ac598c6e
Graph cloning, initial version (not completely working)
Lukas Stadler <lukas.stadler@jku.at>
parents:
2709
diff
changeset
|
112 public Node copy(Graph into) { |
2941
cd4176d590e7
Towards lowering phase.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2918
diff
changeset
|
113 return new LoadField(null, field, into); |
2827
bd17ac598c6e
Graph cloning, initial version (not completely working)
Lukas Stadler <lukas.stadler@jku.at>
parents:
2709
diff
changeset
|
114 } |
2918
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
115 |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
116 @SuppressWarnings("unchecked") |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
117 @Override |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
118 public <T extends Op> T lookup(Class<T> clazz) { |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
119 if (clazz == CanonicalizerOp.class) { |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
120 return (T) CANONICALIZER; |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
121 } |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
122 return super.lookup(clazz); |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
123 } |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
124 |
2947
e86e83c5adbc
More on lowering.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2941
diff
changeset
|
125 private static class LoadFieldLoweringOp implements LoweringOp { |
e86e83c5adbc
More on lowering.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2941
diff
changeset
|
126 |
e86e83c5adbc
More on lowering.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2941
diff
changeset
|
127 @Override |
e86e83c5adbc
More on lowering.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2941
diff
changeset
|
128 public Node lower(Node n, LoweringTool tool) { |
e86e83c5adbc
More on lowering.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2941
diff
changeset
|
129 LoadField field = (LoadField) n; |
e86e83c5adbc
More on lowering.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2941
diff
changeset
|
130 return null;//field.field().createLoad(tool); |
e86e83c5adbc
More on lowering.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2941
diff
changeset
|
131 } |
e86e83c5adbc
More on lowering.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2941
diff
changeset
|
132 |
e86e83c5adbc
More on lowering.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2941
diff
changeset
|
133 } |
e86e83c5adbc
More on lowering.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2941
diff
changeset
|
134 |
2918
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
135 private static class LoadFieldCanonicalizerOp implements CanonicalizerOp { |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
136 @Override |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
137 public Node canonical(Node node) { |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
138 LoadField loadField = (LoadField) node; |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
139 Graph graph = node.graph(); |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
140 CiConstant constant = null; |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
141 if (graph instanceof CompilerGraph) { |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
142 RiMethod method = ((CompilerGraph) graph).getCompilation().method; |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
143 if (loadField.isStatic() && !method.isClassInitializer()) { |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
144 constant = loadField.field().constantValue(null); |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
145 } |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
146 } |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
147 if (!loadField.isStatic()) { |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
148 Value object = loadField.object(); |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
149 if (object.isConstant()) { |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
150 constant = loadField.field().constantValue(object.asConstant()); |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
151 } |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
152 } |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
153 if (constant != null) { |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
154 return new Constant(constant, graph); |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
155 } |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
156 return loadField; |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
157 } |
e7ba2bad98fb
Canonicalize LoadField & ArrayLength
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2874
diff
changeset
|
158 } |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
159 } |