Mercurial > hg > graal-jvmci-8
diff jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java @ 23392:b3a816d3b844
Backed out changeset: a920338dd4d4
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 12 May 2016 11:06:49 +0200 |
parents | a920338dd4d4 |
children | 1d4ce2d19e52 |
line wrap: on
line diff
--- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java Thu May 12 14:24:15 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java Thu May 12 11:06:49 2016 +0200 @@ -22,6 +22,7 @@ */ 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; @@ -30,12 +31,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 @@ -115,27 +116,6 @@ } /** - * 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. */ @@ -206,7 +186,7 @@ checkField(f, entry.getValue()); break; default: - throw new InternalError("unknown kind " + annotation.get()); + throw new JVMCIError("unknown kind %s", annotation.get()); } } else if (f.isAnnotationPresent(HotSpotVMType.class)) { HotSpotVMType annotation = f.getAnnotation(HotSpotVMType.class); @@ -220,7 +200,7 @@ checkField(f, entry.getSize()); break; default: - throw new InternalError("unknown kind " + annotation.get()); + throw new JVMCIError("unknown kind %s", annotation.get()); } } else if (f.isAnnotationPresent(HotSpotVMConstant.class)) { HotSpotVMConstant annotation = f.getAnnotation(HotSpotVMConstant.class); @@ -272,7 +252,7 @@ } else if (value instanceof Long) { assert field.getBoolean(this) == (((long) value) != 0) : field + " " + value + " " + field.getBoolean(this); } else { - throw new InternalError(value.getClass().getSimpleName()); + throw new JVMCIError(value.getClass().getSimpleName()); } } else if (fieldType == int.class) { if (value instanceof Integer) { @@ -280,15 +260,15 @@ } else if (value instanceof Long) { assert field.getInt(this) == (int) (long) value : field + " " + value + " " + field.getInt(this); } else { - throw new InternalError(value.getClass().getSimpleName()); + throw new JVMCIError(value.getClass().getSimpleName()); } } else if (fieldType == long.class) { assert field.getLong(this) == (long) value : field + " " + value + " " + field.getLong(this); } else { - throw new InternalError(field.toString()); + throw new JVMCIError(field.toString()); } } catch (IllegalAccessException e) { - throw new InternalError(String.format("%s: %s", field, e)); + throw new JVMCIError("%s: %s", field, e); } } @@ -408,7 +388,7 @@ if (type.endsWith("*")) { return UNSAFE.getAddress(getAddress()); } - throw new InternalError(type); + throw new JVMCIError(type); } } @@ -726,7 +706,7 @@ case "ccstrlist": return readCString(UNSAFE, getAddr()); default: - throw new InternalError(getType()); + throw new JVMCIError(getType()); } } @@ -1232,14 +1212,14 @@ public long cardtableStartAddress() { if (cardtableStartAddress == -1) { - throw new InternalError("should not reach here"); + throw JVMCIError.shouldNotReachHere(); } return cardtableStartAddress; } public int cardtableShift() { if (cardtableShift == -1) { - throw new InternalError("should not reach here"); + throw JVMCIError.shouldNotReachHere(); } return cardtableShift; }