# HG changeset patch # User Doug Simon # Date 1462974876 -7200 # Node ID a920338dd4d449047668b7f92795e40a2f3ac3cd # Parent 2625b10989ee3440ff48e763c1794e1fd43ead64 remove JVMCIError and UnsafeUtil classes (JDK-8156759) diff -r 2625b10989ee -r a920338dd4d4 jvmci/jdk.vm.ci.common/src/jdk/vm/ci/common/JVMCIError.java --- a/jvmci/jdk.vm.ci.common/src/jdk/vm/ci/common/JVMCIError.java Wed May 11 09:53:28 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,149 +0,0 @@ -/* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.common; - -import java.util.ArrayList; -import java.util.Locale; - -/** - * Indicates a condition in JVMCI related code that should never occur during normal operation. - */ -public class JVMCIError extends Error { - - private static final long serialVersionUID = 531632331813456233L; - private final ArrayList context = new ArrayList<>(); - - public static RuntimeException unimplemented() { - throw new JVMCIError("unimplemented"); - } - - public static RuntimeException unimplemented(String msg) { - throw new JVMCIError("unimplemented: %s", msg); - } - - public static RuntimeException shouldNotReachHere() { - throw new JVMCIError("should not reach here"); - } - - public static RuntimeException shouldNotReachHere(String msg) { - throw new JVMCIError("should not reach here: %s", msg); - } - - public static RuntimeException shouldNotReachHere(Throwable cause) { - throw new JVMCIError(cause); - } - - /** - * Checks a given condition and throws a {@link JVMCIError} if it is false. Guarantees are - * stronger than assertions in that they are always checked. Error messages for guarantee - * violations should clearly indicate the nature of the problem as well as a suggested solution - * if possible. - * - * @param condition the condition to check - * @param msg the message that will be associated with the error, in - * {@link String#format(String, Object...)} syntax - * @param args arguments to the format string - */ - public static void guarantee(boolean condition, String msg, Object... args) { - if (!condition) { - throw new JVMCIError("failed guarantee: " + msg, args); - } - } - - /** - * This constructor creates a {@link JVMCIError} with a given message. - * - * @param msg the message that will be associated with the error - */ - public JVMCIError(String msg) { - super(msg); - } - - /** - * This constructor creates a {@link JVMCIError} with a message assembled via - * {@link String#format(String, Object...)}. It always uses the ENGLISH locale in order to - * always generate the same output. - * - * @param msg the message that will be associated with the error, in String.format syntax - * @param args parameters to String.format - parameters that implement {@link Iterable} will be - * expanded into a [x, x, ...] representation. - */ - public JVMCIError(String msg, Object... args) { - super(format(msg, args)); - } - - /** - * This constructor creates a {@link JVMCIError} for a given causing Throwable instance. - * - * @param cause the original exception that contains additional information on this error - */ - public JVMCIError(Throwable cause) { - super(cause); - } - - /** - * This constructor creates a {@link JVMCIError} and adds all the - * {@linkplain #addContext(String) context} of another {@link JVMCIError}. - * - * @param e the original {@link JVMCIError} - */ - public JVMCIError(JVMCIError e) { - super(e); - context.addAll(e.context); - } - - @Override - public String toString() { - StringBuilder str = new StringBuilder(); - str.append(super.toString()); - for (String s : context) { - str.append("\n\tat ").append(s); - } - return str.toString(); - } - - private static String format(String msg, Object... args) { - if (args != null) { - // expand Iterable parameters into a list representation - for (int i = 0; i < args.length; i++) { - if (args[i] instanceof Iterable) { - ArrayList list = new ArrayList<>(); - for (Object o : (Iterable) args[i]) { - list.add(o); - } - args[i] = list.toString(); - } - } - } - return String.format(Locale.ENGLISH, msg, args); - } - - public JVMCIError addContext(String newContext) { - this.context.add(newContext); - return this; - } - - public JVMCIError addContext(String name, Object obj) { - return addContext(format("%s: %s", name, obj)); - } -} diff -r 2625b10989ee -r a920338dd4d4 jvmci/jdk.vm.ci.common/src/jdk/vm/ci/common/UnsafeUtil.java --- a/jvmci/jdk.vm.ci.common/src/jdk/vm/ci/common/UnsafeUtil.java Wed May 11 09:53:28 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.common; - -import sun.misc.Unsafe; - -/** - * Utilities for operating on raw memory with {@link Unsafe}. - */ -public class UnsafeUtil { - - /** - * Copies the contents of a {@link String} to a native memory buffer as a {@code '\0'} - * terminated C string. The native memory buffer is allocated via - * {@link Unsafe#allocateMemory(long)}. The caller is responsible for releasing the buffer when - * it is no longer needed via {@link Unsafe#freeMemory(long)}. - * - * @return the native memory pointer of the C string created from {@code s} - */ - public static long createCString(Unsafe unsafe, String s) { - return writeCString(unsafe, s, unsafe.allocateMemory(s.length() + 1)); - } - - /** - * Reads a {@code '\0'} terminated C string from native memory and converts it to a - * {@link String}. - * - * @return a Java string - */ - public 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(); - } - - /** - * Writes the contents of a {@link String} to a native memory buffer as a {@code '\0'} - * terminated C string. The caller is responsible for ensuring the buffer is at least - * {@code s.length() + 1} bytes long. The caller is also responsible for releasing the buffer - * when it is no longer. - * - * @return the value of {@code buf} - */ - public static long writeCString(Unsafe unsafe, String s, long buf) { - int size = s.length(); - for (int i = 0; i < size; i++) { - unsafe.putByte(buf + i, (byte) s.charAt(i)); - } - unsafe.putByte(buf + size, (byte) '\0'); - return buf; - } -} diff -r 2625b10989ee -r a920338dd4d4 jvmci/jdk.vm.ci.hotspot.aarch64/src/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotRegisterConfig.java --- a/jvmci/jdk.vm.ci.hotspot.aarch64/src/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotRegisterConfig.java Wed May 11 09:53:28 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot.aarch64/src/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotRegisterConfig.java Wed May 11 15:54:36 2016 +0200 @@ -64,7 +64,6 @@ import jdk.vm.ci.code.RegisterConfig; import jdk.vm.ci.code.StackSlot; import jdk.vm.ci.code.TargetDescription; -import jdk.vm.ci.common.JVMCIError; import jdk.vm.ci.hotspot.HotSpotCallingConventionType; import jdk.vm.ci.hotspot.HotSpotVMConfig; import jdk.vm.ci.meta.AllocatableValue; @@ -226,7 +225,7 @@ case Double: return simdParameterRegisters; default: - throw JVMCIError.shouldNotReachHere(); + throw new InternalError("should not reach here"); } } @@ -261,7 +260,7 @@ } break; default: - throw JVMCIError.shouldNotReachHere(); + throw new InternalError("should not reach here"); } if (locations[i] == null) { diff -r 2625b10989ee -r a920338dd4d4 jvmci/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotRegisterConfig.java --- a/jvmci/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotRegisterConfig.java Wed May 11 09:53:28 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotRegisterConfig.java Wed May 11 15:54:36 2016 +0200 @@ -56,7 +56,6 @@ import jdk.vm.ci.code.RegisterConfig; import jdk.vm.ci.code.StackSlot; import jdk.vm.ci.code.TargetDescription; -import jdk.vm.ci.common.JVMCIError; import jdk.vm.ci.hotspot.HotSpotCallingConventionType; import jdk.vm.ci.hotspot.HotSpotVMConfig; import jdk.vm.ci.meta.AllocatableValue; @@ -223,7 +222,7 @@ case Double: return xmmParameterRegisters; default: - throw JVMCIError.shouldNotReachHere(); + throw new InternalError("should not reach here"); } } @@ -258,7 +257,7 @@ } break; default: - throw JVMCIError.shouldNotReachHere(); + throw new InternalError("should not reach here"); } if (locations[i] == null) { diff -r 2625b10989ee -r a920338dd4d4 jvmci/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotRegisterConfig.java --- a/jvmci/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotRegisterConfig.java Wed May 11 09:53:28 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotRegisterConfig.java Wed May 11 15:54:36 2016 +0200 @@ -78,7 +78,6 @@ import jdk.vm.ci.code.RegisterConfig; import jdk.vm.ci.code.StackSlot; import jdk.vm.ci.code.TargetDescription; -import jdk.vm.ci.common.JVMCIError; import jdk.vm.ci.hotspot.HotSpotCallingConventionType; import jdk.vm.ci.hotspot.HotSpotVMConfig; import jdk.vm.ci.meta.AllocatableValue; @@ -211,7 +210,7 @@ if (type == HotSpotCallingConventionType.JavaCallee) { return callingConvention(cpuCalleeParameterRegisters, returnType, parameterTypes, hotspotType, target); } - throw JVMCIError.shouldNotReachHere(); + throw new InternalError("should not reach here"); } @Override @@ -230,7 +229,7 @@ case Float: return fpuFloatParameterRegisters; default: - throw JVMCIError.shouldNotReachHere("Unknown JavaKind " + kind); + throw new InternalError("should not reach here: unknown JavaKind " + kind); } } @@ -275,7 +274,7 @@ } break; default: - throw JVMCIError.shouldNotReachHere(); + throw new InternalError("should not reach here"); } if (locations[i] == null) { diff -r 2625b10989ee -r a920338dd4d4 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java Wed May 11 09:53:28 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java Wed May 11 15:54:36 2016 +0200 @@ -33,7 +33,6 @@ import jdk.vm.ci.code.InstalledCode; import jdk.vm.ci.code.InvalidInstalledCodeException; import jdk.vm.ci.code.TargetDescription; -import jdk.vm.ci.common.JVMCIError; import jdk.vm.ci.hotspotvmconfig.HotSpotVMField; import jdk.vm.ci.inittimer.InitTimer; import jdk.vm.ci.meta.JavaType; @@ -310,8 +309,8 @@ * {@link HotSpotVMConfig#codeInstallResultCodeTooLarge}, * {@link HotSpotVMConfig#codeInstallResultDependenciesFailed} or * {@link HotSpotVMConfig#codeInstallResultDependenciesInvalid}. - * @throws JVMCIError if there is something wrong with the compiled code or the associated - * metadata. + * @throws InternalError if there is something wrong with the compiled code or the associated + * metadata */ native int installCode(TargetDescription target, HotSpotCompiledCode compiledCode, InstalledCode code, HotSpotSpeculationLog speculationLog); diff -r 2625b10989ee -r a920338dd4d4 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantPool.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantPool.java Wed May 11 09:53:28 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantPool.java Wed May 11 15:54:36 2016 +0200 @@ -29,7 +29,6 @@ import java.lang.invoke.MethodHandle; -import jdk.vm.ci.common.JVMCIError; import jdk.vm.ci.meta.ConstantPool; import jdk.vm.ci.meta.JavaConstant; import jdk.vm.ci.meta.JavaField; @@ -158,7 +157,7 @@ if (res != null) { return res; } - throw new JVMCIError("Unknown JVM_CONSTANT tag %s", tag); + throw new InternalError("Unknown JVM_CONSTANT tag " + tag); } } @@ -508,7 +507,7 @@ Object obj = compilerToVM().resolveConstantInPool(this, cpi); return HotSpotObjectConstantImpl.forObject(obj); default: - throw new JVMCIError("Unknown constant pool tag %s", tag); + throw new InternalError("Unknown constant pool tag " + tag); } } @@ -655,7 +654,7 @@ break; } default: - throw JVMCIError.shouldNotReachHere("Unexpected opcode " + opcode); + throw new InternalError("Unexpected opcode " + opcode); } final JVM_CONSTANT tag = getTagAt(index); diff -r 2625b10989ee -r a920338dd4d4 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantReflectionProvider.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantReflectionProvider.java Wed May 11 09:53:28 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantReflectionProvider.java Wed May 11 15:54:36 2016 +0200 @@ -24,7 +24,6 @@ import java.lang.reflect.Array; -import jdk.vm.ci.common.JVMCIError; import jdk.vm.ci.meta.Constant; import jdk.vm.ci.meta.ConstantReflectionProvider; import jdk.vm.ci.meta.JavaConstant; @@ -198,7 +197,7 @@ if (type instanceof HotSpotResolvedObjectType) { return ((HotSpotResolvedObjectType) type).klass(); } else { - throw JVMCIError.unimplemented(); + throw new InternalError("should not reach here"); } } } diff -r 2625b10989ee -r a920338dd4d4 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java Wed May 11 09:53:28 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java Wed May 11 15:54:36 2016 +0200 @@ -24,7 +24,6 @@ import jdk.vm.ci.code.CompilationRequest; import jdk.vm.ci.code.CompilationRequestResult; -import jdk.vm.ci.common.JVMCIError; import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option; import jdk.vm.ci.runtime.JVMCICompiler; import jdk.vm.ci.runtime.JVMCIRuntime; @@ -36,7 +35,7 @@ private static class DummyCompilerFactory extends JVMCICompilerFactory implements JVMCICompiler { public CompilationRequestResult compileMethod(CompilationRequest request) { - throw new JVMCIError("no JVMCI compiler selected"); + throw new InternalError("no JVMCI compiler selected"); } @Override @@ -72,7 +71,7 @@ } } if (factory == null) { - throw new JVMCIError("JVMCI compiler '%s' not found", compilerName); + throw new InternalError("JVMCI compiler '" + compilerName + "' not found"); } } else { factory = new DummyCompilerFactory(); diff -r 2625b10989ee -r a920338dd4d4 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java Wed May 11 09:53:28 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java Wed May 11 15:54:36 2016 +0200 @@ -41,7 +41,6 @@ import jdk.vm.ci.code.CompilationRequestResult; import jdk.vm.ci.code.CompiledCode; import jdk.vm.ci.code.InstalledCode; -import jdk.vm.ci.common.JVMCIError; import jdk.vm.ci.hotspot.services.HotSpotJVMCICompilerFactory; import jdk.vm.ci.hotspot.services.HotSpotVMEventListener; import jdk.vm.ci.inittimer.InitTimer; @@ -140,7 +139,7 @@ } else if (type == String.class) { this.value = propertyValue; } else { - throw new JVMCIError("Unexpected option type " + type); + throw new InternalError("Unexpected option type " + type); } this.isDefault = false; } @@ -190,7 +189,7 @@ } } - throw new JVMCIError("No JVMCI runtime available for the %s architecture", architecture); + throw new InternalError(String.format("No JVMCI runtime available for the %s architecture", architecture)); } /** diff -r 2625b10989ee -r a920338dd4d4 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntimeProvider.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntimeProvider.java Wed May 11 09:53:28 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntimeProvider.java Wed May 11 15:54:36 2016 +0200 @@ -24,7 +24,6 @@ import java.io.OutputStream; -import jdk.vm.ci.common.JVMCIError; import jdk.vm.ci.meta.JVMCIMetaAccessContext; import jdk.vm.ci.meta.JavaKind; import jdk.vm.ci.meta.JavaType; @@ -98,7 +97,7 @@ case Object: return Unsafe.ARRAY_OBJECT_BASE_OFFSET; default: - throw new JVMCIError("%s", kind); + throw new InternalError(kind.toString()); } } @@ -128,7 +127,7 @@ case Object: return Unsafe.ARRAY_OBJECT_INDEX_SCALE; default: - throw new JVMCIError("%s", kind); + throw new InternalError(kind.toString()); } } } diff -r 2625b10989ee -r a920338dd4d4 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaAccessProvider.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaAccessProvider.java Wed May 11 09:53:28 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaAccessProvider.java Wed May 11 15:54:36 2016 +0200 @@ -36,7 +36,6 @@ import jdk.vm.ci.code.CodeUtil; import jdk.vm.ci.code.TargetDescription; -import jdk.vm.ci.common.JVMCIError; import jdk.vm.ci.meta.DeoptimizationAction; import jdk.vm.ci.meta.DeoptimizationReason; import jdk.vm.ci.meta.JavaConstant; @@ -103,7 +102,7 @@ field.setAccessible(true); return field; } catch (NoSuchFieldException | SecurityException e) { - throw new JVMCIError(e); + throw new InternalError(e); } } @@ -114,7 +113,7 @@ final int slot = slotField.getInt(reflectionMethod); return runtime.getCompilerToVM().getResolvedJavaMethodAtSlot(holder, slot); } catch (IllegalArgumentException | IllegalAccessException e) { - throw new JVMCIError(e); + throw new InternalError(e); } } @@ -138,7 +137,7 @@ } } - throw new JVMCIError("unresolved field %s", reflectionField); + throw new InternalError("unresolved field " + reflectionField); } private static int intMaskRight(int n) { @@ -191,7 +190,7 @@ case InvalidateStopCompiling: return config.deoptActionMakeNotCompilable; default: - throw new JVMCIError("%s", action); + throw new InternalError(action.toString()); } } @@ -212,7 +211,7 @@ if (action == config.deoptActionMakeNotCompilable) { return DeoptimizationAction.InvalidateStopCompiling; } - throw new JVMCIError("%d", action); + throw new InternalError(String.valueOf(action)); } public int convertDeoptReason(DeoptimizationReason reason) { @@ -251,7 +250,7 @@ case TransferToInterpreter: return config.deoptReasonTransferToInterpreter; default: - throw new JVMCIError("%s", reason); + throw new InternalError(reason.toString()); } } @@ -305,7 +304,7 @@ if (reason == config.deoptReasonTransferToInterpreter) { return DeoptimizationReason.TransferToInterpreter; } - throw new JVMCIError("%x", reason); + throw new InternalError(String.format("%x", reason)); } @Override diff -r 2625b10989ee -r a920338dd4d4 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodHandleAccessProvider.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodHandleAccessProvider.java Wed May 11 09:53:28 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodHandleAccessProvider.java Wed May 11 15:54:36 2016 +0200 @@ -25,7 +25,7 @@ import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM; import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; import static jdk.vm.ci.hotspot.HotSpotResolvedObjectTypeImpl.fromObjectClass; -import jdk.vm.ci.common.JVMCIError; + import jdk.vm.ci.meta.ConstantReflectionProvider; import jdk.vm.ci.meta.JavaConstant; import jdk.vm.ci.meta.MethodHandleAccessProvider; @@ -92,7 +92,7 @@ lambdaFormCompileToBytecodeMethod = findMethodInClass("java.lang.invoke.LambdaForm", "compileToBytecode"); memberNameVmtargetField = (HotSpotResolvedJavaField) findFieldInClass("java.lang.invoke.MemberName", "vmtarget"); } catch (Throwable ex) { - throw new JVMCIError(ex); + throw new InternalError(ex); } } } diff -r 2625b10989ee -r a920338dd4d4 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java Wed May 11 09:53:28 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java Wed May 11 15:54:36 2016 +0200 @@ -28,7 +28,6 @@ import java.lang.annotation.Annotation; import java.lang.reflect.Field; -import jdk.vm.ci.common.JVMCIError; import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option; import jdk.vm.ci.meta.JavaType; import jdk.vm.ci.meta.LocationIdentity; @@ -300,7 +299,7 @@ MetaAccessProvider metaAccess = runtime().getHostJVMCIBackend().getMetaAccess(); STRING_VALUE_FIELD = metaAccess.lookupJavaField(String.class.getDeclaredField("value")); } catch (SecurityException | NoSuchFieldException e) { - throw new JVMCIError(e); + throw new InternalError(e); } } } diff -r 2625b10989ee -r a920338dd4d4 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java Wed May 11 09:53:28 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java Wed May 11 15:54:36 2016 +0200 @@ -36,7 +36,6 @@ import java.util.HashMap; import java.util.Map; -import jdk.vm.ci.common.JVMCIError; import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option; import jdk.vm.ci.meta.Constant; import jdk.vm.ci.meta.ConstantPool; @@ -615,7 +614,7 @@ */ public int vtableEntryOffset(ResolvedJavaType resolved) { if (!isInVirtualMethodTable(resolved)) { - throw new JVMCIError("%s does not have a vtable entry in type %s", this, resolved); + throw new InternalError(String.format("%s does not have a vtable entry in type %s", this, resolved)); } HotSpotVMConfig config = config(); final int vtableIndex = getVtableIndex((HotSpotResolvedObjectTypeImpl) resolved); diff -r 2625b10989ee -r a920338dd4d4 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java Wed May 11 09:53:28 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java Wed May 11 15:54:36 2016 +0200 @@ -38,7 +38,6 @@ import java.util.Arrays; import java.util.HashMap; -import jdk.vm.ci.common.JVMCIError; import jdk.vm.ci.meta.Assumptions.AssumptionResult; import jdk.vm.ci.meta.Assumptions.ConcreteMethod; import jdk.vm.ci.meta.Assumptions.ConcreteSubtype; @@ -279,7 +278,7 @@ @Override public HotSpotResolvedObjectTypeImpl getSingleImplementor() { if (!isInterface()) { - throw new JVMCIError("Cannot call getSingleImplementor() on a non-interface type: %s", this); + throw new InternalError("Cannot call getSingleImplementor() on a non-interface type: " + this); } return compilerToVM().getImplementor(this); } diff -r 2625b10989ee -r a920338dd4d4 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java Wed May 11 09:53:28 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java Wed May 11 15:54:36 2016 +0200 @@ -28,7 +28,6 @@ import java.lang.reflect.Array; import java.lang.reflect.Modifier; -import jdk.vm.ci.common.JVMCIError; import jdk.vm.ci.meta.Assumptions.AssumptionResult; import jdk.vm.ci.meta.JavaConstant; import jdk.vm.ci.meta.JavaKind; @@ -95,7 +94,7 @@ @Override public ResolvedJavaType getSingleImplementor() { - throw new JVMCIError("Cannot call getSingleImplementor() on a non-interface type: %s", this); + throw new InternalError("Cannot call getSingleImplementor() on a non-interface type: " + this); } @Override @@ -225,7 +224,7 @@ @Override public String getSourceFileName() { - throw JVMCIError.unimplemented(); + throw new InternalError("should not reach here"); } @Override diff -r 2625b10989ee -r a920338dd4d4 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSignature.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSignature.java Wed May 11 09:53:28 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSignature.java Wed May 11 15:54:36 2016 +0200 @@ -25,7 +25,6 @@ import java.util.ArrayList; import java.util.List; -import jdk.vm.ci.common.JVMCIError; import jdk.vm.ci.meta.JavaKind; import jdk.vm.ci.meta.JavaType; import jdk.vm.ci.meta.ResolvedJavaType; @@ -105,7 +104,7 @@ case 'Z': break; default: - throw new JVMCIError("Invalid character at index %d in signature: %s", cur, signature); + throw new InternalError(String.format("Invalid character at index %d in signature: %s", cur, signature)); } return cur; } diff -r 2625b10989ee -r a920338dd4d4 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java --- 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; } diff -r 2625b10989ee -r a920338dd4d4 jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfigVerifier.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfigVerifier.java Wed May 11 09:53:28 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfigVerifier.java Wed May 11 15:54:36 2016 +0200 @@ -34,7 +34,6 @@ import java.util.Arrays; import java.util.Objects; -import jdk.vm.ci.common.JVMCIError; import jdk.internal.org.objectweb.asm.ClassReader; import jdk.internal.org.objectweb.asm.ClassVisitor; import jdk.internal.org.objectweb.asm.Label; @@ -68,7 +67,7 @@ */ return true; } catch (IOException e) { - throw new JVMCIError(e); + throw new InternalError(e); } } @@ -76,7 +75,7 @@ try { return Class.forName(name.replace('/', '.')); } catch (ClassNotFoundException e) { - throw new JVMCIError(e); + throw new InternalError(e); } } @@ -110,7 +109,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 JVMCIError(errorMessage); + throw new InternalError(errorMessage); } diff -r 2625b10989ee -r a920338dd4d4 jvmci/jdk.vm.ci.hotspotvmconfig.processor/src/jdk/vm/ci/hotspotvmconfig/processor/HotSpotVMConfigProcessor.java --- a/jvmci/jdk.vm.ci.hotspotvmconfig.processor/src/jdk/vm/ci/hotspotvmconfig/processor/HotSpotVMConfigProcessor.java Wed May 11 09:53:28 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspotvmconfig.processor/src/jdk/vm/ci/hotspotvmconfig/processor/HotSpotVMConfigProcessor.java Wed May 11 15:54:36 2016 +0200 @@ -47,7 +47,6 @@ import javax.tools.FileObject; import javax.tools.StandardLocation; -import jdk.vm.ci.common.JVMCIError; import jdk.vm.ci.hotspotvmconfig.HotSpotVMConstant; import jdk.vm.ci.hotspotvmconfig.HotSpotVMField; import jdk.vm.ci.hotspotvmconfig.HotSpotVMFlag; @@ -279,7 +278,7 @@ setter = String.format("set_%s(\"%s\", (%s) (intptr_t) %s);", type, field.getSimpleName(), type, name); break; default: - throw new JVMCIError("unexpected type: " + value.get()); + throw new InternalError("unexpected type: " + value.get()); } } @@ -342,7 +341,7 @@ case "sparc": return "defined(SPARC)"; default: - throw new JVMCIError("unexpected arch: " + arch); + throw new InternalError("unexpected arch: " + arch); } } diff -r 2625b10989ee -r a920338dd4d4 jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java --- a/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java Wed May 11 09:53:28 2016 +0200 +++ b/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java Wed May 11 15:54:36 2016 +0200 @@ -55,7 +55,6 @@ import org.junit.Test; -import jdk.vm.ci.common.JVMCIError; import jdk.vm.ci.meta.Assumptions.AssumptionResult; import jdk.vm.ci.meta.JavaConstant; import jdk.vm.ci.meta.JavaKind; @@ -429,13 +428,13 @@ assertEquals(aSai2, iSai2.getSingleImplementor()); } - @Test(expected = JVMCIError.class) + @Test(expected = InternalError.class) public void getSingleImplementorTestClassReceiver() { ResolvedJavaType base = metaAccess.lookupJavaType(Base.class); base.getSingleImplementor(); } - @Test(expected = JVMCIError.class) + @Test(expected = InternalError.class) public void getSingleImplementorTestPrimitiveReceiver() { ResolvedJavaType primitive = metaAccess.lookupJavaType(int.class); primitive.getSingleImplementor(); diff -r 2625b10989ee -r a920338dd4d4 make/jvmci.make --- a/make/jvmci.make Wed May 11 09:53:28 2016 +0200 +++ b/make/jvmci.make Wed May 11 15:54:36 2016 +0200 @@ -104,7 +104,6 @@ JVMCI_API_SRC += $(shell find jvmci/jdk.vm.ci.meta/src -type f 2> /dev/null) JVMCI_API_SRC += $(shell find jvmci/jdk.vm.ci.code/src -type f 2> /dev/null) JVMCI_API_SRC += $(shell find jvmci/jdk.vm.ci.runtime/src -type f 2> /dev/null) -JVMCI_API_SRC += $(shell find jvmci/jdk.vm.ci.common/src -type f 2> /dev/null) JVMCI_API_SRC += $(shell find jvmci/jdk.vm.ci.aarch64/src -type f 2> /dev/null) JVMCI_API_SRC += $(shell find jvmci/jdk.vm.ci.amd64/src -type f 2> /dev/null) JVMCI_API_SRC += $(shell find jvmci/jdk.vm.ci.sparc/src -type f 2> /dev/null) diff -r 2625b10989ee -r a920338dd4d4 mx.jvmci/suite.py --- a/mx.jvmci/suite.py Wed May 11 09:53:28 2016 +0200 +++ b/mx.jvmci/suite.py Wed May 11 15:54:36 2016 +0200 @@ -70,14 +70,6 @@ # ------------- JVMCI:API ------------- - "jdk.vm.ci.common" : { - "subDir" : "jvmci", - "sourceDirs" : ["src"], - "checkstyle" : "jdk.vm.ci.services", - "javaCompliance" : "1.8", - "workingSets" : "API,JVMCI", - }, - "jdk.vm.ci.meta" : { "subDir" : "jvmci", "sourceDirs" : ["src"], @@ -112,7 +104,6 @@ "sourceDirs" : ["src"], "dependencies" : [ "mx:JUNIT", - "jdk.vm.ci.common", "jdk.vm.ci.runtime", ], "checkstyle" : "jdk.vm.ci.services", @@ -162,7 +153,6 @@ "sourceDirs" : ["src"], "dependencies" : [ "jdk.vm.ci.hotspotvmconfig", - "jdk.vm.ci.common", "jdk.vm.ci.inittimer", "jdk.vm.ci.runtime", ], @@ -185,7 +175,7 @@ "jdk.vm.ci.hotspotvmconfig.processor" : { "subDir" : "jvmci", "sourceDirs" : ["src"], - "dependencies" : ["jdk.vm.ci.hotspotvmconfig", "jdk.vm.ci.common"], + "dependencies" : ["jdk.vm.ci.hotspotvmconfig"], "checkstyle" : "jdk.vm.ci.services", "javaCompliance" : "1.8", "workingSets" : "JVMCI,HotSpot,Codegen", @@ -319,7 +309,6 @@ "dependencies" : [ "jdk.vm.ci.inittimer", "jdk.vm.ci.runtime", - "jdk.vm.ci.common", "jdk.vm.ci.aarch64", "jdk.vm.ci.amd64", "jdk.vm.ci.sparc", diff -r 2625b10989ee -r a920338dd4d4 src/share/vm/jvmci/jvmciRuntime.cpp --- a/src/share/vm/jvmci/jvmciRuntime.cpp Wed May 11 09:53:28 2016 +0200 +++ b/src/share/vm/jvmci/jvmciRuntime.cpp Wed May 11 15:54:36 2016 +0200 @@ -1043,19 +1043,6 @@ vm_abort(dump_core); } -void JVMCIRuntime::fthrow_error(Thread* thread, const char* file, int line, const char* format, ...) { - const int max_msg_size = 1024; - va_list ap; - va_start(ap, format); - char msg[max_msg_size]; - vsnprintf(msg, max_msg_size, format, ap); - msg[max_msg_size-1] = '\0'; - va_end(ap); - Handle h_loader = Handle(thread, SystemDictionary::jvmci_loader()); - Handle h_protection_domain = Handle(); - Exceptions::_throw_msg(thread, file, line, vmSymbols::jdk_vm_ci_common_JVMCIError(), msg, h_loader, h_protection_domain); -} - Klass* JVMCIRuntime::resolve_or_null(Symbol* name, TRAPS) { assert(!UseJVMCIClassLoader || SystemDictionary::jvmci_loader() != NULL, "JVMCI classloader should have been initialized"); return SystemDictionary::resolve_or_null(name, SystemDictionary::jvmci_loader(), Handle(), CHECK_NULL); diff -r 2625b10989ee -r a920338dd4d4 src/share/vm/jvmci/jvmciRuntime.hpp --- a/src/share/vm/jvmci/jvmciRuntime.hpp Wed May 11 09:53:28 2016 +0200 +++ b/src/share/vm/jvmci/jvmciRuntime.hpp Wed May 11 15:54:36 2016 +0200 @@ -32,10 +32,10 @@ #define JVMCI_ERROR(...) \ - { JVMCIRuntime::fthrow_error(THREAD_AND_LOCATION, __VA_ARGS__); return; } + { Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::java_lang_InternalError(), __VA_ARGS__); return; } #define JVMCI_ERROR_(ret, ...) \ - { JVMCIRuntime::fthrow_error(THREAD_AND_LOCATION, __VA_ARGS__); return ret; } + { Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::java_lang_InternalError(), __VA_ARGS__); return ret; } #define JVMCI_ERROR_0(...) JVMCI_ERROR_(0, __VA_ARGS__) #define JVMCI_ERROR_NULL(...) JVMCI_ERROR_(NULL, __VA_ARGS__) @@ -172,13 +172,6 @@ static void parse_lines(char* path, ParseClosure* closure, bool warnStatFailure); /** - * Throws a JVMCIError with a formatted error message. Ideally we would use - * a variation of Exceptions::fthrow that takes a class loader argument but alas, - * no such variation exists. - */ - static void fthrow_error(Thread* thread, const char* file, int line, const char* format, ...) ATTRIBUTE_PRINTF(4, 5); - - /** * Aborts the VM due to an unexpected exception. */ static void abort_on_pending_exception(Handle exception, const char* message, bool dump_core = false); diff -r 2625b10989ee -r a920338dd4d4 src/share/vm/jvmci/vmSymbols_jvmci.hpp --- a/src/share/vm/jvmci/vmSymbols_jvmci.hpp Wed May 11 09:53:28 2016 +0200 +++ b/src/share/vm/jvmci/vmSymbols_jvmci.hpp Wed May 11 15:54:36 2016 +0200 @@ -85,7 +85,6 @@ template(jdk_vm_ci_code_site_Infopoint, "jdk/vm/ci/code/site/Infopoint") \ template(jdk_vm_ci_code_site_Site, "jdk/vm/ci/code/site/Site") \ template(jdk_vm_ci_code_site_InfopointReason, "jdk/vm/ci/code/site/InfopointReason") \ - template(jdk_vm_ci_common_JVMCIError, "jdk/vm/ci/common/JVMCIError") \ template(adjustCompilationLevel_name, "adjustCompilationLevel") \ template(adjustCompilationLevel_signature, "(Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;ZI)I") \ template(compileMethod_name, "compileMethod") \