# HG changeset patch # User Doug Simon # Date 1465997378 -7200 # Node ID 50465926fbeb0eacbb6d0bcec8fc8d5efebb822b # Parent 71becd3e2b1f4a032b9c0b07f77d9bd5170c2527 make all HotSpotVMConfigAccess subclasses and their members package-private remove toString methods from HotSpotVMConfigAccess subclasses remove HotSpotVMConfigVerifier diff -r 71becd3e2b1f -r 50465926fbeb jvmci/jdk.vm.ci.hotspot.aarch64/src/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotVMConfig.java --- a/jvmci/jdk.vm.ci.hotspot.aarch64/src/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotVMConfig.java Wed Jun 15 15:18:17 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot.aarch64/src/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotVMConfig.java Wed Jun 15 15:29:38 2016 +0200 @@ -26,22 +26,20 @@ import jdk.vm.ci.hotspot.HotSpotVMConfigStore; /** - * Used to access native configuration details. - * - * All non-static, public fields in this class are so that they can be compiled as constants. + * Used to access AArch64 specific native configuration details. */ -public class AArch64HotSpotVMConfig extends HotSpotVMConfigAccess { +class AArch64HotSpotVMConfig extends HotSpotVMConfigAccess { - public AArch64HotSpotVMConfig(HotSpotVMConfigStore config) { + AArch64HotSpotVMConfig(HotSpotVMConfigStore config) { super(config); } /** * Maximum allowed size of allocated area for a frame. */ - public final int maxFrameSize = 16 * 1024; + final int maxFrameSize = 16 * 1024; - public final boolean linuxOs = System.getProperty("os.name", "").startsWith("Linux"); + final boolean linuxOs = System.getProperty("os.name", "").startsWith("Linux"); - public final boolean useCompressedOops = getFlag("UseCompressedOops", Boolean.class); + final boolean useCompressedOops = getFlag("UseCompressedOops", Boolean.class); } diff -r 71becd3e2b1f -r 50465926fbeb jvmci/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotVMConfig.java --- a/jvmci/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotVMConfig.java Wed Jun 15 15:18:17 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotVMConfig.java Wed Jun 15 15:29:38 2016 +0200 @@ -25,54 +25,57 @@ import jdk.vm.ci.hotspot.HotSpotVMConfigAccess; import jdk.vm.ci.hotspot.HotSpotVMConfigStore; -public class AMD64HotSpotVMConfig extends HotSpotVMConfigAccess { +/** + * Used to access AMD64 specific native configuration details. + */ +class AMD64HotSpotVMConfig extends HotSpotVMConfigAccess { - public AMD64HotSpotVMConfig(HotSpotVMConfigStore config) { + AMD64HotSpotVMConfig(HotSpotVMConfigStore config) { super(config); } /** * Maximum allowed size of allocated area for a frame. */ - public final int maxFrameSize = 16 * 1024; + final int maxFrameSize = 16 * 1024; - public final boolean windowsOs = System.getProperty("os.name", "").startsWith("Windows"); + final boolean windowsOs = System.getProperty("os.name", "").startsWith("Windows"); - public final boolean useCountLeadingZerosInstruction = getFlag("UseCountLeadingZerosInstruction", Boolean.class); - public final boolean useCountTrailingZerosInstruction = getFlag("UseCountTrailingZerosInstruction", Boolean.class); - public final boolean useCompressedOops = getFlag("UseCompressedOops", Boolean.class); + final boolean useCountLeadingZerosInstruction = getFlag("UseCountLeadingZerosInstruction", Boolean.class); + final boolean useCountTrailingZerosInstruction = getFlag("UseCountTrailingZerosInstruction", Boolean.class); + final boolean useCompressedOops = getFlag("UseCompressedOops", Boolean.class); // CPU capabilities - public final int useSSE = getFlag("UseSSE", Integer.class); - public final int useAVX = getFlag("UseAVX", Integer.class); + final int useSSE = getFlag("UseSSE", Integer.class); + final int useAVX = getFlag("UseAVX", Integer.class); - public final long vmVersionFeatures = getFieldValue("VM_Version::_cpuFeatures", Long.class, "int"); + final long vmVersionFeatures = getFieldValue("VM_Version::_cpuFeatures", Long.class, "int"); // CPU feature flags - public final long amd64CX8 = getConstant("VM_Version::CPU_CX8", Long.class); - public final long amd64CMOV = getConstant("VM_Version::CPU_CMOV", Long.class); - public final long amd64FXSR = getConstant("VM_Version::CPU_FXSR", Long.class); - public final long amd64HT = getConstant("VM_Version::CPU_HT", Long.class); - public final long amd64MMX = getConstant("VM_Version::CPU_MMX", Long.class); - public final long amd643DNOWPREFETCH = getConstant("VM_Version::CPU_3DNOW_PREFETCH", Long.class); - public final long amd64SSE = getConstant("VM_Version::CPU_SSE", Long.class); - public final long amd64SSE2 = getConstant("VM_Version::CPU_SSE2", Long.class); - public final long amd64SSE3 = getConstant("VM_Version::CPU_SSE3", Long.class); - public final long amd64SSSE3 = getConstant("VM_Version::CPU_SSSE3", Long.class); - public final long amd64SSE4A = getConstant("VM_Version::CPU_SSE4A", Long.class); - public final long amd64SSE41 = getConstant("VM_Version::CPU_SSE4_1", Long.class); - public final long amd64SSE42 = getConstant("VM_Version::CPU_SSE4_2", Long.class); - public final long amd64POPCNT = getConstant("VM_Version::CPU_POPCNT", Long.class); - public final long amd64LZCNT = getConstant("VM_Version::CPU_LZCNT", Long.class); - public final long amd64TSC = getConstant("VM_Version::CPU_TSC", Long.class); - public final long amd64TSCINV = getConstant("VM_Version::CPU_TSCINV", Long.class); - public final long amd64AVX = getConstant("VM_Version::CPU_AVX", Long.class); - public final long amd64AVX2 = getConstant("VM_Version::CPU_AVX2", Long.class); - public final long amd64AES = getConstant("VM_Version::CPU_AES", Long.class); - public final long amd64ERMS = getConstant("VM_Version::CPU_ERMS", Long.class); - public final long amd64CLMUL = getConstant("VM_Version::CPU_CLMUL", Long.class); - public final long amd64BMI1 = getConstant("VM_Version::CPU_BMI1", Long.class); - public final long amd64BMI2 = getConstant("VM_Version::CPU_BMI2", Long.class); - public final long amd64RTM = getConstant("VM_Version::CPU_RTM", Long.class); - public final long amd64ADX = getConstant("VM_Version::CPU_ADX", Long.class); + final long amd64CX8 = getConstant("VM_Version::CPU_CX8", Long.class); + final long amd64CMOV = getConstant("VM_Version::CPU_CMOV", Long.class); + final long amd64FXSR = getConstant("VM_Version::CPU_FXSR", Long.class); + final long amd64HT = getConstant("VM_Version::CPU_HT", Long.class); + final long amd64MMX = getConstant("VM_Version::CPU_MMX", Long.class); + final long amd643DNOWPREFETCH = getConstant("VM_Version::CPU_3DNOW_PREFETCH", Long.class); + final long amd64SSE = getConstant("VM_Version::CPU_SSE", Long.class); + final long amd64SSE2 = getConstant("VM_Version::CPU_SSE2", Long.class); + final long amd64SSE3 = getConstant("VM_Version::CPU_SSE3", Long.class); + final long amd64SSSE3 = getConstant("VM_Version::CPU_SSSE3", Long.class); + final long amd64SSE4A = getConstant("VM_Version::CPU_SSE4A", Long.class); + final long amd64SSE41 = getConstant("VM_Version::CPU_SSE4_1", Long.class); + final long amd64SSE42 = getConstant("VM_Version::CPU_SSE4_2", Long.class); + final long amd64POPCNT = getConstant("VM_Version::CPU_POPCNT", Long.class); + final long amd64LZCNT = getConstant("VM_Version::CPU_LZCNT", Long.class); + final long amd64TSC = getConstant("VM_Version::CPU_TSC", Long.class); + final long amd64TSCINV = getConstant("VM_Version::CPU_TSCINV", Long.class); + final long amd64AVX = getConstant("VM_Version::CPU_AVX", Long.class); + final long amd64AVX2 = getConstant("VM_Version::CPU_AVX2", Long.class); + final long amd64AES = getConstant("VM_Version::CPU_AES", Long.class); + final long amd64ERMS = getConstant("VM_Version::CPU_ERMS", Long.class); + final long amd64CLMUL = getConstant("VM_Version::CPU_CLMUL", Long.class); + final long amd64BMI1 = getConstant("VM_Version::CPU_BMI1", Long.class); + final long amd64BMI2 = getConstant("VM_Version::CPU_BMI2", Long.class); + final long amd64RTM = getConstant("VM_Version::CPU_RTM", Long.class); + final long amd64ADX = getConstant("VM_Version::CPU_ADX", Long.class); } diff -r 71becd3e2b1f -r 50465926fbeb jvmci/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotVMConfig.java --- a/jvmci/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotVMConfig.java Wed Jun 15 15:18:17 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotVMConfig.java Wed Jun 15 15:29:38 2016 +0200 @@ -26,48 +26,44 @@ import jdk.vm.ci.hotspot.HotSpotVMConfigStore; /** - * Used to access native configuration details. - * - * All non-static, public fields in this class are so that they can be compiled as constants. + * Used to access SPARC specific native configuration details. */ -public class SPARCHotSpotVMConfig extends HotSpotVMConfigAccess { +class SPARCHotSpotVMConfig extends HotSpotVMConfigAccess { - public SPARCHotSpotVMConfig(HotSpotVMConfigStore config) { + SPARCHotSpotVMConfig(HotSpotVMConfigStore config) { super(config); } - public final boolean linuxOs = System.getProperty("os.name", "").startsWith("Linux"); - - public final boolean useCompressedOops = getFlag("UseCompressedOops", Boolean.class); + final boolean useCompressedOops = getFlag("UseCompressedOops", Boolean.class); // CPU capabilities - public final int vmVersionFeatures = getFieldValue("VM_Version::_features", Integer.class, "int"); + final int vmVersionFeatures = getFieldValue("VM_Version::_features", Integer.class, "int"); // SPARC specific values - public final int sparcVis3Instructions = getConstant("VM_Version::vis3_instructions_m", Integer.class); - public final int sparcVis2Instructions = getConstant("VM_Version::vis2_instructions_m", Integer.class); - public final int sparcVis1Instructions = getConstant("VM_Version::vis1_instructions_m", Integer.class); - public final int sparcCbcondInstructions = getConstant("VM_Version::cbcond_instructions_m", Integer.class); - public final int sparcV8Instructions = getConstant("VM_Version::v8_instructions_m", Integer.class); - public final int sparcHardwareMul32 = getConstant("VM_Version::hardware_mul32_m", Integer.class); - public final int sparcHardwareDiv32 = getConstant("VM_Version::hardware_div32_m", Integer.class); - public final int sparcHardwareFsmuld = getConstant("VM_Version::hardware_fsmuld_m", Integer.class); - public final int sparcHardwarePopc = getConstant("VM_Version::hardware_popc_m", Integer.class); - public final int sparcV9Instructions = getConstant("VM_Version::v9_instructions_m", Integer.class); - public final int sparcSun4v = getConstant("VM_Version::sun4v_m", Integer.class); - public final int sparcBlkInitInstructions = getConstant("VM_Version::blk_init_instructions_m", Integer.class); - public final int sparcFmafInstructions = getConstant("VM_Version::fmaf_instructions_m", Integer.class); - public final int sparcFmauInstructions = getConstant("VM_Version::fmau_instructions_m", Integer.class); - public final int sparcSparc64Family = getConstant("VM_Version::sparc64_family_m", Integer.class); - public final int sparcMFamily = getConstant("VM_Version::M_family_m", Integer.class); - public final int sparcTFamily = getConstant("VM_Version::T_family_m", Integer.class); - public final int sparcT1Model = getConstant("VM_Version::T1_model_m", Integer.class); - public final int sparcSparc5Instructions = getConstant("VM_Version::sparc5_instructions_m", Integer.class); - public final int sparcAesInstructions = getConstant("VM_Version::aes_instructions_m", Integer.class); - public final int sparcSha1Instruction = getConstant("VM_Version::sha1_instruction_m", Integer.class); - public final int sparcSha256Instruction = getConstant("VM_Version::sha256_instruction_m", Integer.class); - public final int sparcSha512Instruction = getConstant("VM_Version::sha512_instruction_m", Integer.class); + final int sparcVis3Instructions = getConstant("VM_Version::vis3_instructions_m", Integer.class); + final int sparcVis2Instructions = getConstant("VM_Version::vis2_instructions_m", Integer.class); + final int sparcVis1Instructions = getConstant("VM_Version::vis1_instructions_m", Integer.class); + final int sparcCbcondInstructions = getConstant("VM_Version::cbcond_instructions_m", Integer.class); + final int sparcV8Instructions = getConstant("VM_Version::v8_instructions_m", Integer.class); + final int sparcHardwareMul32 = getConstant("VM_Version::hardware_mul32_m", Integer.class); + final int sparcHardwareDiv32 = getConstant("VM_Version::hardware_div32_m", Integer.class); + final int sparcHardwareFsmuld = getConstant("VM_Version::hardware_fsmuld_m", Integer.class); + final int sparcHardwarePopc = getConstant("VM_Version::hardware_popc_m", Integer.class); + final int sparcV9Instructions = getConstant("VM_Version::v9_instructions_m", Integer.class); + final int sparcSun4v = getConstant("VM_Version::sun4v_m", Integer.class); + final int sparcBlkInitInstructions = getConstant("VM_Version::blk_init_instructions_m", Integer.class); + final int sparcFmafInstructions = getConstant("VM_Version::fmaf_instructions_m", Integer.class); + final int sparcFmauInstructions = getConstant("VM_Version::fmau_instructions_m", Integer.class); + final int sparcSparc64Family = getConstant("VM_Version::sparc64_family_m", Integer.class); + final int sparcMFamily = getConstant("VM_Version::M_family_m", Integer.class); + final int sparcTFamily = getConstant("VM_Version::T_family_m", Integer.class); + final int sparcT1Model = getConstant("VM_Version::T1_model_m", Integer.class); + final int sparcSparc5Instructions = getConstant("VM_Version::sparc5_instructions_m", Integer.class); + final int sparcAesInstructions = getConstant("VM_Version::aes_instructions_m", Integer.class); + final int sparcSha1Instruction = getConstant("VM_Version::sha1_instruction_m", Integer.class); + final int sparcSha256Instruction = getConstant("VM_Version::sha256_instruction_m", Integer.class); + final int sparcSha512Instruction = getConstant("VM_Version::sha512_instruction_m", Integer.class); - public final boolean useBlockZeroing = getFlag("UseBlockZeroing", Boolean.class); - public final int blockZeroingLowLimit = getFlag("BlockZeroingLowLimit", Integer.class); + final boolean useBlockZeroing = getFlag("UseBlockZeroing", Boolean.class); + final int blockZeroingLowLimit = getFlag("BlockZeroingLowLimit", Integer.class); } diff -r 71becd3e2b1f -r 50465926fbeb 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 Jun 15 15:18:17 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java Wed Jun 15 15:29:38 2016 +0200 @@ -36,14 +36,6 @@ @SuppressWarnings("try") HotSpotVMConfig(HotSpotVMConfigStore store) { super(store); - - assert check(); - assert HotSpotVMConfigVerifier.check(); - } - - @Override - public String toString() { - return getClass().getSimpleName(); } /** @@ -385,10 +377,4 @@ final int arrayDataArrayLenOffset = getConstant("ArrayData::array_len_off_set", Integer.class); final int arrayDataArrayStartOffset = getConstant("ArrayData::array_start_off_set", Integer.class); final int multiBranchDataPerCaseCellCount = getConstant("MultiBranchData::per_case_cell_count", Integer.class); - - boolean check() { - assert (layoutHelperArrayTagObjectValue & (1 << (Integer.SIZE - 1))) != 0 : "object array must have first bit set"; - assert (layoutHelperArrayTagTypeValue & (1 << (Integer.SIZE - 1))) != 0 : "type array must have first bit set"; - return true; - } } diff -r 71becd3e2b1f -r 50465926fbeb jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfigAccess.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfigAccess.java Wed Jun 15 15:18:17 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfigAccess.java Wed Jun 15 15:29:38 2016 +0200 @@ -324,9 +324,4 @@ public HotSpotVMConfigAccess(HotSpotVMConfigStore store) { this.store = store; } - - @Override - public String toString() { - return getClass().getSimpleName(); - } } diff -r 71becd3e2b1f -r 50465926fbeb 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 Jun 15 15:18:17 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,174 +0,0 @@ -/* - * Copyright (c) 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.hotspot; - -import static java.lang.String.format; - -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.Constructor; -import java.lang.reflect.Executable; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.security.AccessControlException; -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; -import jdk.internal.org.objectweb.asm.MethodVisitor; -import jdk.internal.org.objectweb.asm.Opcodes; -import jdk.internal.org.objectweb.asm.Type; -import sun.misc.Unsafe; - -/** - * A verifier that checks that {@link HotSpotVMConfig} does not access {@link Unsafe} from any of - * its non-static, non-constructor methods. This ensures that a deserialized {@link HotSpotVMConfig} - * object does not perform any unsafe reads on addresses that are only valid in the context in which - * the object was serialized. Note that this does not catch cases where a client uses an address - * stored in a {@link HotSpotVMConfig} field. - */ -final class HotSpotVMConfigVerifier { - - public static boolean check() { - Class cls = HotSpotVMConfig.class; - String classFilePath = "/" + cls.getName().replace('.', '/') + ".class"; - try { - InputStream classfile = cls.getResourceAsStream(classFilePath); - ClassReader cr = new ClassReader(Objects.requireNonNull(classfile, "Could not find class file for " + cls.getName())); - ClassVisitor cv = new Verifier(); - cr.accept(cv, 0); - return true; - } catch (AccessControlException e) { - /* - * When running with a security manager and +UseJVMCIClassLoader the ASM classes might - * not be accessible. - */ - return true; - } catch (IOException e) { - throw new JVMCIError(e); - } - } - - private static Class resolve(String name) { - try { - return Class.forName(name.replace('/', '.')); - } catch (ClassNotFoundException e) { - throw new JVMCIError(e); - } - } - - private static class Verifier extends ClassVisitor { - - /** - * Source file context for error reporting. - */ - String sourceFile = null; - - /** - * Line number for error reporting. - */ - int lineNo = -1; - - Verifier() { - super(Opcodes.ASM5); - } - - @Override - public void visitSource(String source, String debug) { - this.sourceFile = source; - } - - void verify(boolean condition, String message) { - if (!condition) { - error(message); - } - } - - 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); - - } - - @Override - public MethodVisitor visitMethod(int access, String name, String d, String signature, String[] exceptions) { - if (!Modifier.isStatic(access) && Modifier.isPublic(access) && !name.equals("")) { - return new MethodVisitor(Opcodes.ASM5) { - - @Override - public void visitLineNumber(int line, Label start) { - lineNo = line; - } - - private Executable resolveMethod(String owner, String methodName, String methodDesc) { - Class declaringClass = resolve(owner); - while (declaringClass != null) { - if (methodName.equals("")) { - for (Constructor c : declaringClass.getDeclaredConstructors()) { - if (methodDesc.equals(Type.getConstructorDescriptor(c))) { - return c; - } - } - } else { - Type[] argumentTypes = Type.getArgumentTypes(methodDesc); - for (Method m : declaringClass.getDeclaredMethods()) { - if (m.getName().equals(methodName)) { - if (Arrays.equals(argumentTypes, Type.getArgumentTypes(m))) { - if (Type.getReturnType(methodDesc).equals(Type.getReturnType(m))) { - return m; - } - } - } - } - } - declaringClass = declaringClass.getSuperclass(); - } - throw new NoSuchMethodError(owner + "." + methodName + methodDesc); - } - - /** - * Checks whether a given method is allowed to be called. - */ - private boolean checkInvokeTarget(Executable method) { - if (method.getDeclaringClass().equals(Unsafe.class)) { - return false; - } - return true; - } - - @Override - public void visitMethodInsn(int opcode, String owner, String methodName, String methodDesc, boolean itf) { - Executable callee = resolveMethod(owner, methodName, methodDesc); - verify(checkInvokeTarget(callee), "invocation of " + callee); - } - }; - } else { - return null; - } - } - } -}