Mercurial > hg > graal-jvmci-8
diff 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 |
line wrap: on
line diff
--- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java Wed May 11 09:53:28 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java Wed May 11 15:54:36 2016 +0200 @@ -22,7 +22,6 @@ */ package jdk.vm.ci.hotspot; -import static jdk.vm.ci.common.UnsafeUtil.readCString; import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; @@ -31,12 +30,12 @@ import java.util.HashMap; import java.util.Iterator; -import jdk.vm.ci.common.JVMCIError; import jdk.vm.ci.hotspotvmconfig.HotSpotVMConstant; import jdk.vm.ci.hotspotvmconfig.HotSpotVMField; import jdk.vm.ci.hotspotvmconfig.HotSpotVMFlag; import jdk.vm.ci.hotspotvmconfig.HotSpotVMType; import jdk.vm.ci.hotspotvmconfig.HotSpotVMValue; +import sun.misc.Unsafe; //JaCoCo Exclude @@ -116,6 +115,27 @@ } /** + * Reads a {@code '\0'} terminated C string from native memory and converts it to a + * {@link String}. + * + * @return a Java string + */ + static String readCString(Unsafe unsafe, long address) { + if (address == 0) { + return null; + } + StringBuilder sb = new StringBuilder(); + for (int i = 0;; i++) { + char c = (char) unsafe.getByte(address + i); + if (c == 0) { + break; + } + sb.append(c); + } + return sb.toString(); + } + + /** * Check that the initialization produces the same result as the values captured through * vmStructs. */ @@ -186,7 +206,7 @@ checkField(f, entry.getValue()); break; default: - throw new JVMCIError("unknown kind %s", annotation.get()); + throw new InternalError("unknown kind " + annotation.get()); } } else if (f.isAnnotationPresent(HotSpotVMType.class)) { HotSpotVMType annotation = f.getAnnotation(HotSpotVMType.class); @@ -200,7 +220,7 @@ checkField(f, entry.getSize()); break; default: - throw new JVMCIError("unknown kind %s", annotation.get()); + throw new InternalError("unknown kind " + annotation.get()); } } else if (f.isAnnotationPresent(HotSpotVMConstant.class)) { HotSpotVMConstant annotation = f.getAnnotation(HotSpotVMConstant.class); @@ -252,7 +272,7 @@ } else if (value instanceof Long) { assert field.getBoolean(this) == (((long) value) != 0) : field + " " + value + " " + field.getBoolean(this); } else { - throw new JVMCIError(value.getClass().getSimpleName()); + throw new InternalError(value.getClass().getSimpleName()); } } else if (fieldType == int.class) { if (value instanceof Integer) { @@ -260,15 +280,15 @@ } else if (value instanceof Long) { assert field.getInt(this) == (int) (long) value : field + " " + value + " " + field.getInt(this); } else { - throw new JVMCIError(value.getClass().getSimpleName()); + throw new InternalError(value.getClass().getSimpleName()); } } else if (fieldType == long.class) { assert field.getLong(this) == (long) value : field + " " + value + " " + field.getLong(this); } else { - throw new JVMCIError(field.toString()); + throw new InternalError(field.toString()); } } catch (IllegalAccessException e) { - throw new JVMCIError("%s: %s", field, e); + throw new InternalError(String.format("%s: %s", field, e)); } } @@ -388,7 +408,7 @@ if (type.endsWith("*")) { return UNSAFE.getAddress(getAddress()); } - throw new JVMCIError(type); + throw new InternalError(type); } } @@ -706,7 +726,7 @@ case "ccstrlist": return readCString(UNSAFE, getAddr()); default: - throw new JVMCIError(getType()); + throw new InternalError(getType()); } } @@ -1212,14 +1232,14 @@ public long cardtableStartAddress() { if (cardtableStartAddress == -1) { - throw JVMCIError.shouldNotReachHere(); + throw new InternalError("should not reach here"); } return cardtableStartAddress; } public int cardtableShift() { if (cardtableShift == -1) { - throw JVMCIError.shouldNotReachHere(); + throw new InternalError("should not reach here"); } return cardtableShift; }