# HG changeset patch # User Doug Simon # Date 1432590299 -7200 # Node ID abfdac702f14d7d15b7485d292afeedf0a45913b # Parent 93c50cefb9e8bc6cf0a9ebac30652edd3cfe470e reverted uses of InternalError to JVMCIError (JBS:GRAAL-53) diff -r 93c50cefb9e8 -r abfdac702f14 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotCodeCacheProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotCodeCacheProvider.java Mon May 25 23:30:34 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotCodeCacheProvider.java Mon May 25 23:44:59 2015 +0200 @@ -39,6 +39,7 @@ import com.oracle.graal.api.code.DataSection.DataBuilder; import com.oracle.graal.api.meta.*; import com.oracle.graal.debug.*; +import com.oracle.jvmci.common.*; /** * HotSpot implementation of {@link CodeCacheProvider}. @@ -119,7 +120,7 @@ return (String) processMethod.invoke(null, hcfEmbeddedString); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { // If the tool is available, for now let's be noisy when it fails - throw new InternalError(e); + throw new JVMCIError(e); } } return hcfEmbeddedString; @@ -279,7 +280,7 @@ compressed = meta.isCompressed(); raw = meta.rawValue(); } else { - throw new InternalError(String.valueOf(constant)); + throw new JVMCIError(String.valueOf(constant)); } size = target.getSizeInBytes(compressed ? Kind.Int : target.wordKind); @@ -304,7 +305,7 @@ size = s.getSerializedSize(); builder = DataBuilder.serializable(s); } else { - throw new InternalError(String.valueOf(constant)); + throw new JVMCIError(String.valueOf(constant)); } return new Data(size, size, builder); diff -r 93c50cefb9e8 -r abfdac702f14 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotConstantPool.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotConstantPool.java Mon May 25 23:30:34 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotConstantPool.java Mon May 25 23:44:59 2015 +0200 @@ -28,6 +28,7 @@ import java.lang.invoke.*; import com.oracle.graal.api.meta.*; +import com.oracle.jvmci.common.*; /** * Implementation of {@link ConstantPool} for HotSpot. @@ -138,7 +139,7 @@ if (res != null) { return res; } - throw new InternalError("Unknown JVM_CONSTANT tag " + tag); + throw new JVMCIError("Unknown JVM_CONSTANT tag %s", tag); } } @@ -451,7 +452,7 @@ Object obj = runtime().getCompilerToVM().resolveConstantInPool(metaspaceConstantPool, cpi); return HotSpotObjectConstantImpl.forObject(obj); default: - throw new InternalError("Unknown constant pool tag " + tag); + throw new JVMCIError("Unknown constant pool tag %s", tag); } } diff -r 93c50cefb9e8 -r abfdac702f14 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotJVMCIRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotJVMCIRuntime.java Mon May 25 23:30:34 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotJVMCIRuntime.java Mon May 25 23:44:59 2015 +0200 @@ -33,6 +33,7 @@ import com.oracle.graal.debug.*; import com.oracle.graal.hotspot.jvmci.logging.*; import com.oracle.graal.options.*; +import com.oracle.jvmci.common.*; import com.oracle.jvmci.runtime.*; //JaCoCo Exclude @@ -129,7 +130,7 @@ if (!Options.JVMCIRuntime.getValue().equals("")) { // Fail fast if a non-default value for JVMCIRuntime was specified // and the corresponding factory is not available - throw new InternalError(String.format("Specified runtime \"%s\" not available for the %s architecture", Options.JVMCIRuntime.getValue(), architecture)); + throw new JVMCIError("Specified runtime \"%s\" not available for the %s architecture", Options.JVMCIRuntime.getValue(), architecture); } else if (nonBasicCount == 1) { // If there is exactly one non-basic runtime, select this one. return nonBasic; diff -r 93c50cefb9e8 -r abfdac702f14 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotJVMCIRuntimeProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotJVMCIRuntimeProvider.java Mon May 25 23:30:34 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotJVMCIRuntimeProvider.java Mon May 25 23:44:59 2015 +0200 @@ -25,6 +25,7 @@ import sun.misc.*; import com.oracle.graal.api.meta.*; +import com.oracle.jvmci.common.*; import com.oracle.jvmci.runtime.*; //JaCoCo Exclude @@ -86,7 +87,7 @@ case Object: return Unsafe.ARRAY_OBJECT_BASE_OFFSET; default: - throw new InternalError(kind.toString()); + throw new JVMCIError("%s", kind); } } @@ -116,7 +117,7 @@ case Object: return Unsafe.ARRAY_OBJECT_INDEX_SCALE; default: - throw new InternalError(kind.toString()); + throw new JVMCIError("%s", kind); } } } diff -r 93c50cefb9e8 -r abfdac702f14 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotMemoryAccessProviderImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotMemoryAccessProviderImpl.java Mon May 25 23:30:34 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotMemoryAccessProviderImpl.java Mon May 25 23:44:59 2015 +0200 @@ -27,6 +27,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.hotspot.jvmci.HotSpotVMConfig.CompressEncoding; +import com.oracle.jvmci.common.*; /** * HotSpot implementation of {@link MemoryAccessProvider}. @@ -59,7 +60,7 @@ return ((HotSpotResolvedObjectTypeImpl) metaspaceObject).mirror().isArray(); } } else { - throw new InternalError(String.valueOf(metaspaceObject)); + throw new JVMCIError("%s", metaspaceObject); } } return false; @@ -74,7 +75,7 @@ return prim.asLong(); } } - throw new InternalError(String.valueOf(base)); + throw new JVMCIError("%s", base); } private static long readRawValue(Constant baseConstant, long displacement, int bits) { @@ -90,7 +91,7 @@ case 64: return unsafe.getLong(base, displacement); default: - throw new InternalError(String.valueOf(bits)); + throw new JVMCIError("%d", bits); } } else { long pointer = asRawPointer(baseConstant); @@ -104,7 +105,7 @@ case 64: return unsafe.getLong(pointer + displacement); default: - throw new InternalError(String.valueOf(bits)); + throw new JVMCIError("%d", bits); } } } @@ -178,7 +179,7 @@ case Double: return JavaConstant.forDouble(Double.longBitsToDouble(rawValue)); default: - throw new InternalError("Unsupported kind: " + kind); + throw new JVMCIError("Unsupported kind: %s", kind); } } catch (NullPointerException e) { return null; diff -r 93c50cefb9e8 -r abfdac702f14 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotMetaAccessProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotMetaAccessProvider.java Mon May 25 23:30:34 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotMetaAccessProvider.java Mon May 25 23:44:59 2015 +0200 @@ -30,6 +30,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; +import com.oracle.jvmci.common.*; /** * HotSpot implementation of {@link MetaAccessProvider}. @@ -76,7 +77,7 @@ field.setAccessible(true); return field; } catch (NoSuchFieldException | SecurityException e) { - throw new InternalError(e); + throw new JVMCIError(e); } } @@ -88,7 +89,7 @@ final long metaspaceMethod = runtime.getCompilerToVM().getMetaspaceMethod(holder, slot); return HotSpotResolvedJavaMethodImpl.fromMetaspace(metaspaceMethod); } catch (IllegalArgumentException | IllegalAccessException e) { - throw new InternalError(e); + throw new JVMCIError(e); } } @@ -108,7 +109,7 @@ HotSpotResolvedObjectType resolved = holder; return resolved.createField(name, type, offset, modifiers); } else { - throw new InternalError("unresolved field " + reflectionField); + throw new JVMCIError("unresolved field %s", reflectionField); } } @@ -161,7 +162,7 @@ case InvalidateStopCompiling: return config.deoptActionMakeNotCompilable; default: - throw new InternalError(action.toString()); + throw new JVMCIError("%s", action); } } @@ -182,7 +183,7 @@ if (action == config.deoptActionMakeNotCompilable) { return DeoptimizationAction.InvalidateStopCompiling; } - throw new InternalError(String.valueOf(action)); + throw new JVMCIError("%d", action); } public int convertDeoptReason(DeoptimizationReason reason) { @@ -221,7 +222,7 @@ case TransferToInterpreter: return config.deoptReasonTransferToInterpreter; default: - throw new InternalError(reason.toString()); + throw new JVMCIError("%s", reason); } } @@ -275,7 +276,7 @@ if (reason == config.deoptReasonTransferToInterpreter) { return DeoptimizationReason.TransferToInterpreter; } - throw new InternalError(Integer.toHexString(reason)); + throw new JVMCIError("%x", reason); } @Override diff -r 93c50cefb9e8 -r abfdac702f14 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotMethodHandleAccessProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotMethodHandleAccessProvider.java Mon May 25 23:30:34 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotMethodHandleAccessProvider.java Mon May 25 23:44:59 2015 +0200 @@ -27,6 +27,7 @@ import static com.oracle.graal.hotspot.jvmci.HotSpotResolvedObjectTypeImpl.*; import com.oracle.graal.api.meta.*; +import com.oracle.jvmci.common.*; public class HotSpotMethodHandleAccessProvider implements MethodHandleAccessProvider, HotSpotProxified { @@ -87,7 +88,7 @@ lambdaFormCompileToBytecodeMethod = findMethodInClass("java.lang.invoke.LambdaForm", "compileToBytecode"); memberNameVmtargetField = findFieldInClass("java.lang.invoke.MemberName", "vmtarget"); } catch (Throwable ex) { - throw new InternalError(ex); + throw new JVMCIError(ex); } } } diff -r 93c50cefb9e8 -r abfdac702f14 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotReferenceMap.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotReferenceMap.java Mon May 25 23:30:34 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotReferenceMap.java Mon May 25 23:44:59 2015 +0200 @@ -27,6 +27,7 @@ import com.oracle.graal.api.code.CodeUtil.RefMapFormatter; import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; +import com.oracle.jvmci.common.*; public final class HotSpotReferenceMap extends ReferenceMap { @@ -346,7 +347,7 @@ private void set(HotSpotOopMap refMap, int index, LIRKind kind) { if (kind.isDerivedReference()) { - throw new InternalError("derived reference cannot be inserted in ReferenceMap"); + throw new JVMCIError("derived reference cannot be inserted in ReferenceMap"); } int bytesPerElement = bytesPerElement(kind); diff -r 93c50cefb9e8 -r abfdac702f14 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotResolvedJavaFieldImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotResolvedJavaFieldImpl.java Mon May 25 23:30:34 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotResolvedJavaFieldImpl.java Mon May 25 23:44:59 2015 +0200 @@ -31,6 +31,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.options.*; +import com.oracle.jvmci.common.*; /** * Represents a field in a HotSpot type. @@ -277,7 +278,7 @@ MetaAccessProvider metaAccess = runtime().getHostJVMCIBackend().getMetaAccess(); STRING_VALUE_FIELD = metaAccess.lookupJavaField(String.class.getDeclaredField("value")); } catch (SecurityException | NoSuchFieldException e) { - throw new InternalError(e); + throw new JVMCIError(e); } } } diff -r 93c50cefb9e8 -r abfdac702f14 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotResolvedJavaMethodImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotResolvedJavaMethodImpl.java Mon May 25 23:30:34 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotResolvedJavaMethodImpl.java Mon May 25 23:44:59 2015 +0200 @@ -36,6 +36,7 @@ import com.oracle.graal.graphbuilderconf.*; import com.oracle.graal.nodes.*; import com.oracle.graal.options.*; +import com.oracle.jvmci.common.*; /** * Implementation of {@link JavaMethod} for resolved HotSpot methods. @@ -627,7 +628,7 @@ */ public int vtableEntryOffset(ResolvedJavaType resolved) { if (!isInVirtualMethodTable(resolved)) { - throw new InternalError(this + " does not have a vtable entry"); + throw new JVMCIError("%s does not have a vtable entry", this); } HotSpotVMConfig config = runtime().getConfig(); final int vtableIndex = getVtableIndex((HotSpotResolvedObjectTypeImpl) resolved); diff -r 93c50cefb9e8 -r abfdac702f14 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotResolvedObjectTypeImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotResolvedObjectTypeImpl.java Mon May 25 23:30:34 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotResolvedObjectTypeImpl.java Mon May 25 23:44:59 2015 +0200 @@ -38,6 +38,7 @@ import com.oracle.graal.api.meta.Assumptions.LeafType; import com.oracle.graal.api.meta.Assumptions.NoFinalizableSubclass; import com.oracle.graal.api.meta.*; +import com.oracle.jvmci.common.*; /** * Implementation of {@link JavaType} for resolved non-primitive HotSpot classes. @@ -231,7 +232,7 @@ @Override public HotSpotResolvedObjectTypeImpl getSingleImplementor() { if (!isInterface()) { - throw new InternalError("Cannot call getSingleImplementor() on a non-interface type: " + this); + throw new JVMCIError("Cannot call getSingleImplementor() on a non-interface type: %s", this); } final long implementorMetaspaceKlass = runtime().getCompilerToVM().getKlassImplementor(getMetaspaceKlass()); diff -r 93c50cefb9e8 -r abfdac702f14 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotResolvedPrimitiveType.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotResolvedPrimitiveType.java Mon May 25 23:30:34 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotResolvedPrimitiveType.java Mon May 25 23:44:59 2015 +0200 @@ -30,6 +30,7 @@ import com.oracle.graal.api.meta.Assumptions.AssumptionResult; import com.oracle.graal.api.meta.*; +import com.oracle.jvmci.common.*; /** * Implementation of {@link JavaType} for primitive HotSpot types. @@ -94,7 +95,7 @@ @Override public ResolvedJavaType getSingleImplementor() { - throw new InternalError("Cannot call getSingleImplementor() on a non-interface type: " + this); + throw new JVMCIError("Cannot call getSingleImplementor() on a non-interface type: %s", this); } @Override @@ -104,12 +105,12 @@ @Override public JavaConstant getObjectHub() { - throw new InternalError(); + throw JVMCIError.unimplemented(); } @Override public JavaConstant getJavaClass() { - throw new InternalError(); + throw JVMCIError.unimplemented(); } @Override @@ -229,7 +230,7 @@ @Override public String getSourceFileName() { - throw new InternalError(); + throw JVMCIError.unimplemented(); } @Override diff -r 93c50cefb9e8 -r abfdac702f14 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotSignature.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotSignature.java Mon May 25 23:30:34 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotSignature.java Mon May 25 23:44:59 2015 +0200 @@ -25,6 +25,7 @@ import java.util.*; import com.oracle.graal.api.meta.*; +import com.oracle.jvmci.common.*; /** * Represents a method signature. @@ -100,7 +101,7 @@ case 'Z': break; default: - throw new InternalError("Invalid character at index " + cur + " in signature: " + signature); + throw new JVMCIError("Invalid character at index %d in signature: %s", cur, signature); } return cur; } diff -r 93c50cefb9e8 -r abfdac702f14 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotVMConfig.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotVMConfig.java Mon May 25 23:30:34 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotVMConfig.java Mon May 25 23:44:59 2015 +0200 @@ -28,6 +28,7 @@ import java.util.*; import com.oracle.graal.hotspotvmconfig.*; +import com.oracle.jvmci.common.*; //JaCoCo Exclude @@ -170,7 +171,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); @@ -184,7 +185,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); @@ -236,7 +237,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) { @@ -244,15 +245,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(field.toString() + ": " + e); + throw new JVMCIError("%s: %s", field, e); } } @@ -372,7 +373,7 @@ if (type.endsWith("*")) { return unsafe.getAddress(getAddress()); } - throw new InternalError(type); + throw new JVMCIError(type); } } @@ -690,7 +691,7 @@ case "ccstrlist": return readCString(getAddr()); default: - throw new InternalError(getType()); + throw new JVMCIError(getType()); } } @@ -1168,14 +1169,14 @@ public long cardtableStartAddress() { if (cardtableStartAddress == -1) { - throw new InternalError(); + throw JVMCIError.shouldNotReachHere(); } return cardtableStartAddress; } public int cardtableShift() { if (cardtableShift == -1) { - throw new InternalError(); + throw JVMCIError.shouldNotReachHere(); } return cardtableShift; } diff -r 93c50cefb9e8 -r abfdac702f14 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotVMConfigVerifier.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotVMConfigVerifier.java Mon May 25 23:30:34 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotVMConfigVerifier.java Mon May 25 23:44:59 2015 +0200 @@ -32,6 +32,8 @@ import jdk.internal.org.objectweb.asm.Type; import sun.misc.*; +import com.oracle.jvmci.common.*; + /** * A {@link ClassVisitor} that verifies {@link HotSpotVMConfig} does not access {@link Unsafe} from * any of its non-static, non-constructor methods. This ensures that a deserialized @@ -51,7 +53,7 @@ cr.accept(cv, 0); return true; } catch (IOException e) { - throw new InternalError(e); + throw new JVMCIError(e); } } @@ -69,7 +71,7 @@ try { return Class.forName(name.replace('/', '.')); } catch (ClassNotFoundException e) { - throw new InternalError(e); + throw new JVMCIError(e); } } @@ -91,7 +93,7 @@ void error(String message) { String errorMessage = format("%s:%d: %s is not allowed in the context of compilation replay. The unsafe access should be moved into the %s constructor and the result cached in a field", sourceFile, lineNo, message, HotSpotVMConfig.class.getSimpleName()); - throw new InternalError(errorMessage); + throw new JVMCIError(errorMessage); }