comparison c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTypeUnresolved.java @ 1941:79d04223b8a5

Added caching for resolved types and resolved fields. This is crucial, because the local load elimination will lead to wrong results, if field equality (of two RiField objects with the same object and the same RiType) is not given. The caching makes sure that the default equals implementation is sufficient.
author Thomas Wuerthinger <wuerthinger@ssw.jku.at>
date Tue, 28 Dec 2010 18:33:26 +0100
parents 2fe369533fed
children 177398c6147d
comparison
equal deleted inserted replaced
1940:e92a9a73324e 1941:79d04223b8a5
30 */ 30 */
31 public class HotSpotTypeUnresolved implements HotSpotType { 31 public class HotSpotTypeUnresolved implements HotSpotType {
32 32
33 public final String name; 33 public final String name;
34 public final int dimensions; 34 public final int dimensions;
35 private final long accessingClassVmId;
36 35
37 /** 36 /**
38 * Creates a new unresolved type for a specified type descriptor. 37 * Creates a new unresolved type for a specified type descriptor.
39 */ 38 */
40 public HotSpotTypeUnresolved(String name, long accessingClassVmId) { 39 public HotSpotTypeUnresolved(String name) {
41 assert name.length() > 0 : "name cannot be empty"; 40 assert name.length() > 0 : "name cannot be empty";
42 41
43 int dimensions = 0; 42 int dimensions = 0;
44 // Decode name if necessary. 43 // Decode name if necessary.
45 if (name.charAt(name.length() - 1) == ';') { 44 if (name.charAt(name.length() - 1) == ';') {
52 name = name.substring(startIndex + 1, name.length() - 1); 51 name = name.substring(startIndex + 1, name.length() - 1);
53 } 52 }
54 53
55 this.name = name; 54 this.name = name;
56 this.dimensions = dimensions; 55 this.dimensions = dimensions;
57 this.accessingClassVmId = accessingClassVmId;
58 } 56 }
59 57
60 public HotSpotTypeUnresolved(String name, int dimensions, long accessingClassVmId) { 58 public HotSpotTypeUnresolved(String name, int dimensions) {
61 assert dimensions >= 0; 59 assert dimensions >= 0;
62 this.name = name; 60 this.name = name;
63 this.dimensions = dimensions; 61 this.dimensions = dimensions;
64 this.accessingClassVmId = accessingClassVmId;
65 } 62 }
66 63
67 @Override 64 @Override
68 public String name() { 65 public String name() {
69 StringBuilder str = new StringBuilder(); 66 StringBuilder str = new StringBuilder();
140 } 137 }
141 138
142 @Override 139 @Override
143 public RiType componentType() { 140 public RiType componentType() {
144 assert isArrayClass() : "no array class" + name(); 141 assert isArrayClass() : "no array class" + name();
145 return new HotSpotTypeUnresolved(name, dimensions - 1, accessingClassVmId); 142 return new HotSpotTypeUnresolved(name, dimensions - 1);
146 } 143 }
147 144
148 @Override 145 @Override
149 public RiType exactType() { 146 public RiType exactType() {
150 throw unresolved("exactType()"); 147 throw unresolved("exactType()");
151 } 148 }
152 149
153 @Override 150 @Override
154 public RiType arrayOf() { 151 public RiType arrayOf() {
155 return new HotSpotTypeUnresolved(name, dimensions + 1, accessingClassVmId); 152 return new HotSpotTypeUnresolved(name, dimensions + 1);
156 } 153 }
157 154
158 @Override 155 @Override
159 public RiMethod resolveMethodImpl(RiMethod method) { 156 public RiMethod resolveMethodImpl(RiMethod method) {
160 throw unresolved("resolveMethodImpl()"); 157 throw unresolved("resolveMethodImpl()");