comparison graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiVirtualObject.java @ 5506:56860d3f9f39

More refactorings and renamings in preparation of ci/ri split.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Thu, 07 Jun 2012 18:12:01 +0200
parents 438ab53efdd0
children dc71b06d09f8
comparison
equal deleted inserted replaced
5505:28af6dff047f 5506:56860d3f9f39
26 26
27 /** 27 /**
28 * An instance of this class represents an object whose allocation was removed by escape analysis. The information stored in the {@link CiVirtualObject} is used during 28 * An instance of this class represents an object whose allocation was removed by escape analysis. The information stored in the {@link CiVirtualObject} is used during
29 * deoptimization to recreate the object. 29 * deoptimization to recreate the object.
30 */ 30 */
31 public final class CiVirtualObject extends CiValue { 31 public final class CiVirtualObject extends RiValue {
32 private static final long serialVersionUID = -2907197776426346021L; 32 private static final long serialVersionUID = -2907197776426346021L;
33 33
34 private final RiType type; 34 private final RiType type;
35 private CiValue[] values; 35 private RiValue[] values;
36 private final int id; 36 private final int id;
37 37
38 /** 38 /**
39 * Creates a new CiVirtualObject for the given type, with the given fields. If the type is an instance class then the values array needs to have one entry for each field, ordered in 39 * Creates a new CiVirtualObject for the given type, with the given fields. If the type is an instance class then the values array needs to have one entry for each field, ordered in
40 * like the fields returned by {@link RiResolvedType#declaredFields()}. If the type is an array then the length of the values array determines the reallocated array length. 40 * like the fields returned by {@link RiResolvedType#declaredFields()}. If the type is an array then the length of the values array determines the reallocated array length.
41 * @param type the type of the object whose allocation was removed during compilation. This can be either an instance of an array type. 41 * @param type the type of the object whose allocation was removed during compilation. This can be either an instance of an array type.
42 * @param values an array containing all the values to be stored into the object when it is recreated. 42 * @param values an array containing all the values to be stored into the object when it is recreated.
43 * @param id a unique id that identifies the object within the debug information for one position in the compiled code. 43 * @param id a unique id that identifies the object within the debug information for one position in the compiled code.
44 * @return a new CiVirtualObject instance. 44 * @return a new CiVirtualObject instance.
45 */ 45 */
46 public static CiVirtualObject get(RiType type, CiValue[] values, int id) { 46 public static CiVirtualObject get(RiType type, RiValue[] values, int id) {
47 return new CiVirtualObject(type, values, id); 47 return new CiVirtualObject(type, values, id);
48 } 48 }
49 49
50 private CiVirtualObject(RiType type, CiValue[] values, int id) { 50 private CiVirtualObject(RiType type, RiValue[] values, int id) {
51 super(RiKind.Object); 51 super(RiKind.Object);
52 this.type = type; 52 this.type = type;
53 this.values = values; 53 this.values = values;
54 this.id = id; 54 this.id = id;
55 } 55 }
67 } 67 }
68 68
69 /** 69 /**
70 * @return an array containing all the values to be stored into the object when it is recreated. 70 * @return an array containing all the values to be stored into the object when it is recreated.
71 */ 71 */
72 public CiValue[] values() { 72 public RiValue[] values() {
73 return values; 73 return values;
74 } 74 }
75 75
76 /** 76 /**
77 * @return the unique id that identifies the object within the debug information for one position in the compiled code. 77 * @return the unique id that identifies the object within the debug information for one position in the compiled code.
82 82
83 /** 83 /**
84 * Overwrites the current set of values with a new one. 84 * Overwrites the current set of values with a new one.
85 * @param values an array containing all the values to be stored into the object when it is recreated. 85 * @param values an array containing all the values to be stored into the object when it is recreated.
86 */ 86 */
87 public void setValues(CiValue[] values) { 87 public void setValues(RiValue[] values) {
88 this.values = values; 88 this.values = values;
89 } 89 }
90 90
91 @Override 91 @Override
92 public int hashCode() { 92 public int hashCode() {
122 122
123 public CiVirtualObjectFactory(RiRuntime runtime) { 123 public CiVirtualObjectFactory(RiRuntime runtime) {
124 this.runtime = runtime; 124 this.runtime = runtime;
125 } 125 }
126 126
127 public CiVirtualObject constantProxy(RiKind kind, CiValue objectValue, CiValue primitiveValue) { 127 public CiVirtualObject constantProxy(RiKind kind, RiValue objectValue, RiValue primitiveValue) {
128 RiConstant cKind = RiConstant.forObject(kind); 128 RiConstant cKind = RiConstant.forObject(kind);
129 // TODO: here the ordering is hard coded... we should query RiType.fields() and act accordingly 129 // TODO: here the ordering is hard coded... we should query RiType.fields() and act accordingly
130 return new CiVirtualObject(runtime.getType(RiConstant.class), new CiValue[] {cKind, primitiveValue, CiValue.IllegalValue, objectValue}, nextId++); 130 return new CiVirtualObject(runtime.getType(RiConstant.class), new RiValue[] {cKind, primitiveValue, RiValue.IllegalValue, objectValue}, nextId++);
131 } 131 }
132 132
133 public CiValue proxy(CiValue ciValue) { 133 public RiValue proxy(RiValue ciValue) {
134 switch (ciValue.kind) { 134 switch (ciValue.kind) {
135 case Boolean: 135 case Boolean:
136 return new CiVirtualObject(runtime.getType(Boolean.class), new CiValue[] {ciValue}, nextId++); 136 return new CiVirtualObject(runtime.getType(Boolean.class), new RiValue[] {ciValue}, nextId++);
137 case Byte: 137 case Byte:
138 return new CiVirtualObject(runtime.getType(Byte.class), new CiValue[] {ciValue}, nextId++); 138 return new CiVirtualObject(runtime.getType(Byte.class), new RiValue[] {ciValue}, nextId++);
139 case Char: 139 case Char:
140 return new CiVirtualObject(runtime.getType(Character.class), new CiValue[] {ciValue}, nextId++); 140 return new CiVirtualObject(runtime.getType(Character.class), new RiValue[] {ciValue}, nextId++);
141 case Double: 141 case Double:
142 return new CiVirtualObject(runtime.getType(Double.class), new CiValue[] {ciValue, CiValue.IllegalValue}, nextId++); 142 return new CiVirtualObject(runtime.getType(Double.class), new RiValue[] {ciValue, RiValue.IllegalValue}, nextId++);
143 case Float: 143 case Float:
144 return new CiVirtualObject(runtime.getType(Float.class), new CiValue[] {ciValue}, nextId++); 144 return new CiVirtualObject(runtime.getType(Float.class), new RiValue[] {ciValue}, nextId++);
145 case Int: 145 case Int:
146 return new CiVirtualObject(runtime.getType(Integer.class), new CiValue[] {ciValue}, nextId++); 146 return new CiVirtualObject(runtime.getType(Integer.class), new RiValue[] {ciValue}, nextId++);
147 case Long: 147 case Long:
148 return new CiVirtualObject(runtime.getType(Long.class), new CiValue[] {ciValue, CiValue.IllegalValue}, nextId++); 148 return new CiVirtualObject(runtime.getType(Long.class), new RiValue[] {ciValue, RiValue.IllegalValue}, nextId++);
149 case Object: 149 case Object:
150 return ciValue; 150 return ciValue;
151 case Short: 151 case Short:
152 return new CiVirtualObject(runtime.getType(Short.class), new CiValue[] {ciValue}, nextId++); 152 return new CiVirtualObject(runtime.getType(Short.class), new RiValue[] {ciValue}, nextId++);
153 default: 153 default:
154 assert false : ciValue.kind; 154 assert false : ciValue.kind;
155 return null; 155 return null;
156 } 156 }
157 } 157 }
158 158
159 public CiVirtualObject arrayProxy(RiType arrayType, CiValue[] values) { 159 public CiVirtualObject arrayProxy(RiType arrayType, RiValue[] values) {
160 return new CiVirtualObject(arrayType, values, nextId++); 160 return new CiVirtualObject(arrayType, values, nextId++);
161 } 161 }
162 162
163 } 163 }
164 } 164 }