Mercurial > hg > graal-jvmci-8
comparison jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java @ 23387:a920338dd4d4
remove JVMCIError and UnsafeUtil classes (JDK-8156759)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 11 May 2016 15:54:36 +0200 |
parents | 24505bf61633 |
children | b3a816d3b844 |
comparison
equal
deleted
inserted
replaced
23386:2625b10989ee | 23387:a920338dd4d4 |
---|---|
20 * or visit www.oracle.com if you need additional information or have any | 20 * or visit www.oracle.com if you need additional information or have any |
21 * questions. | 21 * questions. |
22 */ | 22 */ |
23 package jdk.vm.ci.hotspot; | 23 package jdk.vm.ci.hotspot; |
24 | 24 |
25 import static jdk.vm.ci.common.UnsafeUtil.readCString; | |
26 import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; | 25 import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; |
27 import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; | 26 import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; |
28 | 27 |
29 import java.lang.reflect.Field; | 28 import java.lang.reflect.Field; |
30 import java.lang.reflect.Modifier; | 29 import java.lang.reflect.Modifier; |
31 import java.util.HashMap; | 30 import java.util.HashMap; |
32 import java.util.Iterator; | 31 import java.util.Iterator; |
33 | 32 |
34 import jdk.vm.ci.common.JVMCIError; | |
35 import jdk.vm.ci.hotspotvmconfig.HotSpotVMConstant; | 33 import jdk.vm.ci.hotspotvmconfig.HotSpotVMConstant; |
36 import jdk.vm.ci.hotspotvmconfig.HotSpotVMField; | 34 import jdk.vm.ci.hotspotvmconfig.HotSpotVMField; |
37 import jdk.vm.ci.hotspotvmconfig.HotSpotVMFlag; | 35 import jdk.vm.ci.hotspotvmconfig.HotSpotVMFlag; |
38 import jdk.vm.ci.hotspotvmconfig.HotSpotVMType; | 36 import jdk.vm.ci.hotspotvmconfig.HotSpotVMType; |
39 import jdk.vm.ci.hotspotvmconfig.HotSpotVMValue; | 37 import jdk.vm.ci.hotspotvmconfig.HotSpotVMValue; |
38 import sun.misc.Unsafe; | |
40 | 39 |
41 //JaCoCo Exclude | 40 //JaCoCo Exclude |
42 | 41 |
43 /** | 42 /** |
44 * Used to access native configuration details. | 43 * Used to access native configuration details. |
114 assert check(); | 113 assert check(); |
115 assert HotSpotVMConfigVerifier.check(); | 114 assert HotSpotVMConfigVerifier.check(); |
116 } | 115 } |
117 | 116 |
118 /** | 117 /** |
118 * Reads a {@code '\0'} terminated C string from native memory and converts it to a | |
119 * {@link String}. | |
120 * | |
121 * @return a Java string | |
122 */ | |
123 static String readCString(Unsafe unsafe, long address) { | |
124 if (address == 0) { | |
125 return null; | |
126 } | |
127 StringBuilder sb = new StringBuilder(); | |
128 for (int i = 0;; i++) { | |
129 char c = (char) unsafe.getByte(address + i); | |
130 if (c == 0) { | |
131 break; | |
132 } | |
133 sb.append(c); | |
134 } | |
135 return sb.toString(); | |
136 } | |
137 | |
138 /** | |
119 * Check that the initialization produces the same result as the values captured through | 139 * Check that the initialization produces the same result as the values captured through |
120 * vmStructs. | 140 * vmStructs. |
121 */ | 141 */ |
122 private boolean verifyInitialization() { | 142 private boolean verifyInitialization() { |
123 /** These fields are set in {@link CompilerToVM#initializeConfiguration}. */ | 143 /** These fields are set in {@link CompilerToVM#initializeConfiguration}. */ |
184 break; | 204 break; |
185 case VALUE: | 205 case VALUE: |
186 checkField(f, entry.getValue()); | 206 checkField(f, entry.getValue()); |
187 break; | 207 break; |
188 default: | 208 default: |
189 throw new JVMCIError("unknown kind %s", annotation.get()); | 209 throw new InternalError("unknown kind " + annotation.get()); |
190 } | 210 } |
191 } else if (f.isAnnotationPresent(HotSpotVMType.class)) { | 211 } else if (f.isAnnotationPresent(HotSpotVMType.class)) { |
192 HotSpotVMType annotation = f.getAnnotation(HotSpotVMType.class); | 212 HotSpotVMType annotation = f.getAnnotation(HotSpotVMType.class); |
193 String name = annotation.name(); | 213 String name = annotation.name(); |
194 VMTypes.Type entry = vmTypes.get(name); | 214 VMTypes.Type entry = vmTypes.get(name); |
198 switch (annotation.get()) { | 218 switch (annotation.get()) { |
199 case SIZE: | 219 case SIZE: |
200 checkField(f, entry.getSize()); | 220 checkField(f, entry.getSize()); |
201 break; | 221 break; |
202 default: | 222 default: |
203 throw new JVMCIError("unknown kind %s", annotation.get()); | 223 throw new InternalError("unknown kind " + annotation.get()); |
204 } | 224 } |
205 } else if (f.isAnnotationPresent(HotSpotVMConstant.class)) { | 225 } else if (f.isAnnotationPresent(HotSpotVMConstant.class)) { |
206 HotSpotVMConstant annotation = f.getAnnotation(HotSpotVMConstant.class); | 226 HotSpotVMConstant annotation = f.getAnnotation(HotSpotVMConstant.class); |
207 String name = annotation.name(); | 227 String name = annotation.name(); |
208 AbstractConstant entry = vmConstants.get(name); | 228 AbstractConstant entry = vmConstants.get(name); |
250 } else if (value instanceof Boolean) { | 270 } else if (value instanceof Boolean) { |
251 assert field.getBoolean(this) == (boolean) value : field + " " + value + " " + field.getBoolean(this); | 271 assert field.getBoolean(this) == (boolean) value : field + " " + value + " " + field.getBoolean(this); |
252 } else if (value instanceof Long) { | 272 } else if (value instanceof Long) { |
253 assert field.getBoolean(this) == (((long) value) != 0) : field + " " + value + " " + field.getBoolean(this); | 273 assert field.getBoolean(this) == (((long) value) != 0) : field + " " + value + " " + field.getBoolean(this); |
254 } else { | 274 } else { |
255 throw new JVMCIError(value.getClass().getSimpleName()); | 275 throw new InternalError(value.getClass().getSimpleName()); |
256 } | 276 } |
257 } else if (fieldType == int.class) { | 277 } else if (fieldType == int.class) { |
258 if (value instanceof Integer) { | 278 if (value instanceof Integer) { |
259 assert field.getInt(this) == (int) value : field + " " + value + " " + field.getInt(this); | 279 assert field.getInt(this) == (int) value : field + " " + value + " " + field.getInt(this); |
260 } else if (value instanceof Long) { | 280 } else if (value instanceof Long) { |
261 assert field.getInt(this) == (int) (long) value : field + " " + value + " " + field.getInt(this); | 281 assert field.getInt(this) == (int) (long) value : field + " " + value + " " + field.getInt(this); |
262 } else { | 282 } else { |
263 throw new JVMCIError(value.getClass().getSimpleName()); | 283 throw new InternalError(value.getClass().getSimpleName()); |
264 } | 284 } |
265 } else if (fieldType == long.class) { | 285 } else if (fieldType == long.class) { |
266 assert field.getLong(this) == (long) value : field + " " + value + " " + field.getLong(this); | 286 assert field.getLong(this) == (long) value : field + " " + value + " " + field.getLong(this); |
267 } else { | 287 } else { |
268 throw new JVMCIError(field.toString()); | 288 throw new InternalError(field.toString()); |
269 } | 289 } |
270 } catch (IllegalAccessException e) { | 290 } catch (IllegalAccessException e) { |
271 throw new JVMCIError("%s: %s", field, e); | 291 throw new InternalError(String.format("%s: %s", field, e)); |
272 } | 292 } |
273 } | 293 } |
274 | 294 |
275 /** | 295 /** |
276 * Gets the host architecture name for the purpose of finding the corresponding | 296 * Gets the host architecture name for the purpose of finding the corresponding |
386 default: | 406 default: |
387 // All foo* types are addresses. | 407 // All foo* types are addresses. |
388 if (type.endsWith("*")) { | 408 if (type.endsWith("*")) { |
389 return UNSAFE.getAddress(getAddress()); | 409 return UNSAFE.getAddress(getAddress()); |
390 } | 410 } |
391 throw new JVMCIError(type); | 411 throw new InternalError(type); |
392 } | 412 } |
393 } | 413 } |
394 | 414 |
395 @Override | 415 @Override |
396 public String toString() { | 416 public String toString() { |
704 return Double.valueOf(UNSAFE.getDouble(getAddr())); | 724 return Double.valueOf(UNSAFE.getDouble(getAddr())); |
705 case "ccstr": | 725 case "ccstr": |
706 case "ccstrlist": | 726 case "ccstrlist": |
707 return readCString(UNSAFE, getAddr()); | 727 return readCString(UNSAFE, getAddr()); |
708 default: | 728 default: |
709 throw new JVMCIError(getType()); | 729 throw new InternalError(getType()); |
710 } | 730 } |
711 } | 731 } |
712 | 732 |
713 @Override | 733 @Override |
714 public String toString() { | 734 public String toString() { |
1210 private final long cardtableStartAddress; | 1230 private final long cardtableStartAddress; |
1211 private final int cardtableShift; | 1231 private final int cardtableShift; |
1212 | 1232 |
1213 public long cardtableStartAddress() { | 1233 public long cardtableStartAddress() { |
1214 if (cardtableStartAddress == -1) { | 1234 if (cardtableStartAddress == -1) { |
1215 throw JVMCIError.shouldNotReachHere(); | 1235 throw new InternalError("should not reach here"); |
1216 } | 1236 } |
1217 return cardtableStartAddress; | 1237 return cardtableStartAddress; |
1218 } | 1238 } |
1219 | 1239 |
1220 public int cardtableShift() { | 1240 public int cardtableShift() { |
1221 if (cardtableShift == -1) { | 1241 if (cardtableShift == -1) { |
1222 throw JVMCIError.shouldNotReachHere(); | 1242 throw new InternalError("should not reach here"); |
1223 } | 1243 } |
1224 return cardtableShift; | 1244 return cardtableShift; |
1225 } | 1245 } |
1226 | 1246 |
1227 @HotSpotVMField(name = "os::_polling_page", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long safepointPollingAddress; | 1247 @HotSpotVMField(name = "os::_polling_page", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long safepointPollingAddress; |