# HG changeset patch # User rschatz # Date 1466095310 0 # Node ID 0f8dc369349929742a7291fc165fa0e24db6801b # Parent 52e7ddc77845d6aa5b58069f4fabec7ef8ac4d32 8159167: [JVMCI] fix HotSpotVMConfig startup performance Reviewed-by: iveresov diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/.mx.jvmci/suite.py --- a/hotspot/.mx.jvmci/suite.py Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/.mx.jvmci/suite.py Thu Jun 16 16:41:50 2016 +0000 @@ -149,7 +149,6 @@ "subDir" : "src/jdk.vm.ci/share/classes", "sourceDirs" : ["src"], "dependencies" : [ - "jdk.vm.ci.hotspotvmconfig", "jdk.vm.ci.common", "jdk.vm.ci.runtime", "jdk.vm.ci.services", @@ -175,14 +174,6 @@ "workingSets" : "API,JVMCI", }, - "jdk.vm.ci.hotspotvmconfig" : { - "subDir" : "src/jdk.vm.ci/share/classes", - "sourceDirs" : ["src"], - "checkstyle" : "jdk.vm.ci.services", - "javaCompliance" : "9", - "workingSets" : "JVMCI,HotSpot", - }, - "jdk.vm.ci.hotspot.aarch64" : { "subDir" : "src/jdk.vm.ci/share/classes", "sourceDirs" : ["src"], @@ -248,13 +239,6 @@ ], }, - "JVMCI_HOTSPOTVMCONFIG" : { - "subDir" : "src/jdk.vm.ci/share/classes", - "dependencies" : [ - "jdk.vm.ci.hotspotvmconfig", - ], - }, - "JVMCI_HOTSPOT" : { "subDir" : "src/jdk.vm.ci/share/classes", "dependencies" : [ @@ -263,7 +247,6 @@ "jdk.vm.ci.hotspot.sparc", ], "distDependencies" : [ - "JVMCI_HOTSPOTVMCONFIG", "JVMCI_SERVICES", "JVMCI_API", ], diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.aarch64/src/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotJVMCIBackendFactory.java --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.aarch64/src/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotJVMCIBackendFactory.java Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.aarch64/src/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotJVMCIBackendFactory.java Thu Jun 16 16:41:50 2016 +0000 @@ -38,24 +38,23 @@ import jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider; import jdk.vm.ci.hotspot.HotSpotMetaAccessProvider; import jdk.vm.ci.hotspot.HotSpotStackIntrospection; -import jdk.vm.ci.hotspot.HotSpotVMConfig; import jdk.vm.ci.meta.ConstantReflectionProvider; import jdk.vm.ci.runtime.JVMCIBackend; public class AArch64HotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFactory { - protected EnumSet computeFeatures(@SuppressWarnings("unused") HotSpotVMConfig config) { + protected EnumSet computeFeatures(@SuppressWarnings("unused") AArch64HotSpotVMConfig config) { // Configure the feature set using the HotSpot flag settings. EnumSet features = EnumSet.noneOf(AArch64.CPUFeature.class); return features; } - protected EnumSet computeFlags(@SuppressWarnings("unused") HotSpotVMConfig config) { + protected EnumSet computeFlags(@SuppressWarnings("unused") AArch64HotSpotVMConfig config) { EnumSet flags = EnumSet.noneOf(AArch64.Flag.class); return flags; } - protected TargetDescription createTarget(HotSpotVMConfig config) { + protected TargetDescription createTarget(AArch64HotSpotVMConfig config) { final int stackFrameAlignment = 16; final int implicitNullCheckLimit = 4096; final boolean inlineObjects = true; @@ -67,8 +66,8 @@ return new HotSpotConstantReflectionProvider(runtime); } - protected RegisterConfig createRegisterConfig(HotSpotJVMCIRuntimeProvider runtime, TargetDescription target) { - return new AArch64HotSpotRegisterConfig(target, runtime.getConfig()); + protected RegisterConfig createRegisterConfig(AArch64HotSpotVMConfig config, TargetDescription target) { + return new AArch64HotSpotRegisterConfig(target, config.useCompressedOops); } protected HotSpotCodeCacheProvider createCodeCache(HotSpotJVMCIRuntimeProvider runtime, TargetDescription target, RegisterConfig regConfig) { @@ -93,7 +92,8 @@ public JVMCIBackend createJVMCIBackend(HotSpotJVMCIRuntimeProvider runtime, JVMCIBackend host) { assert host == null; - TargetDescription target = createTarget(runtime.getConfig()); + AArch64HotSpotVMConfig config = new AArch64HotSpotVMConfig(runtime.getConfigStore()); + TargetDescription target = createTarget(config); RegisterConfig regConfig; HotSpotCodeCacheProvider codeCache; @@ -105,7 +105,7 @@ metaAccess = createMetaAccess(runtime); } try (InitTimer rt = timer("create RegisterConfig")) { - regConfig = createRegisterConfig(runtime, target); + regConfig = createRegisterConfig(config, target); } try (InitTimer rt = timer("create CodeCache provider")) { codeCache = createCodeCache(runtime, target, regConfig); diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.aarch64/src/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotRegisterConfig.java --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.aarch64/src/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotRegisterConfig.java Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.aarch64/src/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotRegisterConfig.java Thu Jun 16 16:41:50 2016 +0000 @@ -67,7 +67,6 @@ import jdk.vm.ci.code.ValueKindFactory; import jdk.vm.ci.common.JVMCIError; import jdk.vm.ci.hotspot.HotSpotCallingConventionType; -import jdk.vm.ci.hotspot.HotSpotVMConfig; import jdk.vm.ci.meta.AllocatableValue; import jdk.vm.ci.meta.JavaKind; import jdk.vm.ci.meta.JavaType; @@ -81,8 +80,6 @@ private final Register[] allocatable; - private final int maxFrameSize; - /** * The caller saved registers always include all parameter registers. */ @@ -92,10 +89,6 @@ private final RegisterAttributes[] attributesMap; - public int getMaximumFrameSize() { - return maxFrameSize; - } - @Override public Register[] getAllocatableRegisters() { return allocatable.clone(); @@ -160,14 +153,13 @@ return registers; } - public AArch64HotSpotRegisterConfig(TargetDescription target, HotSpotVMConfig config) { - this(target, config, initAllocatable(target.arch, config.useCompressedOops)); + public AArch64HotSpotRegisterConfig(TargetDescription target, boolean useCompressedOops) { + this(target, initAllocatable(target.arch, useCompressedOops)); assert callerSaved.length >= allocatable.length; } - public AArch64HotSpotRegisterConfig(TargetDescription target, HotSpotVMConfig config, Register[] allocatable) { + public AArch64HotSpotRegisterConfig(TargetDescription target, Register[] allocatable) { this.target = target; - this.maxFrameSize = config.maxFrameSize; this.allocatable = allocatable.clone(); Set callerSaveSet = new HashSet<>(); diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.aarch64/src/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotVMConfig.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.aarch64/src/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotVMConfig.java Thu Jun 16 16:41:50 2016 +0000 @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2016, 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.aarch64; + +import jdk.vm.ci.hotspot.HotSpotVMConfigAccess; +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. + */ +class AArch64HotSpotVMConfig extends HotSpotVMConfigAccess { + + AArch64HotSpotVMConfig(HotSpotVMConfigStore config) { + super(config); + } + + /** + * Maximum allowed size of allocated area for a frame. + */ + final int maxFrameSize = 16 * 1024; + + final boolean linuxOs = System.getProperty("os.name", "").startsWith("Linux"); + + final boolean useCompressedOops = getFlag("UseCompressedOops", Boolean.class); +} diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotJVMCIBackendFactory.java --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotJVMCIBackendFactory.java Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotJVMCIBackendFactory.java Thu Jun 16 16:41:50 2016 +0000 @@ -38,13 +38,12 @@ import jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider; import jdk.vm.ci.hotspot.HotSpotMetaAccessProvider; import jdk.vm.ci.hotspot.HotSpotStackIntrospection; -import jdk.vm.ci.hotspot.HotSpotVMConfig; import jdk.vm.ci.meta.ConstantReflectionProvider; import jdk.vm.ci.runtime.JVMCIBackend; public class AMD64HotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFactory { - protected EnumSet computeFeatures(HotSpotVMConfig config) { + protected EnumSet computeFeatures(AMD64HotSpotVMConfig config) { // Configure the feature set using the HotSpot flag settings. EnumSet features = EnumSet.noneOf(AMD64.CPUFeature.class); if ((config.vmVersionFeatures & config.amd643DNOWPREFETCH) != 0) { @@ -128,7 +127,7 @@ return features; } - protected EnumSet computeFlags(HotSpotVMConfig config) { + protected EnumSet computeFlags(AMD64HotSpotVMConfig config) { EnumSet flags = EnumSet.noneOf(AMD64.Flag.class); if (config.useCountLeadingZerosInstruction) { flags.add(AMD64.Flag.UseCountLeadingZerosInstruction); @@ -139,7 +138,7 @@ return flags; } - protected TargetDescription createTarget(HotSpotVMConfig config) { + protected TargetDescription createTarget(AMD64HotSpotVMConfig config) { final int stackFrameAlignment = 16; final int implicitNullCheckLimit = 4096; final boolean inlineObjects = true; @@ -151,8 +150,8 @@ return new HotSpotConstantReflectionProvider(runtime); } - protected RegisterConfig createRegisterConfig(HotSpotJVMCIRuntimeProvider runtime, TargetDescription target) { - return new AMD64HotSpotRegisterConfig(target, runtime.getConfig()); + protected RegisterConfig createRegisterConfig(AMD64HotSpotVMConfig config, TargetDescription target) { + return new AMD64HotSpotRegisterConfig(target, config.useCompressedOops, config.windowsOs); } protected HotSpotCodeCacheProvider createCodeCache(HotSpotJVMCIRuntimeProvider runtime, TargetDescription target, RegisterConfig regConfig) { @@ -175,9 +174,9 @@ @SuppressWarnings("try") public JVMCIBackend createJVMCIBackend(HotSpotJVMCIRuntimeProvider runtime, JVMCIBackend host) { - assert host == null; - TargetDescription target = createTarget(runtime.getConfig()); + AMD64HotSpotVMConfig config = new AMD64HotSpotVMConfig(runtime.getConfigStore()); + TargetDescription target = createTarget(config); RegisterConfig regConfig; HotSpotCodeCacheProvider codeCache; @@ -189,7 +188,7 @@ metaAccess = createMetaAccess(runtime); } try (InitTimer rt = timer("create RegisterConfig")) { - regConfig = createRegisterConfig(runtime, target); + regConfig = createRegisterConfig(config, target); } try (InitTimer rt = timer("create CodeCache provider")) { codeCache = createCodeCache(runtime, target, regConfig); diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotRegisterConfig.java --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotRegisterConfig.java Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotRegisterConfig.java Thu Jun 16 16:41:50 2016 +0000 @@ -59,7 +59,6 @@ import jdk.vm.ci.code.ValueKindFactory; import jdk.vm.ci.common.JVMCIError; import jdk.vm.ci.hotspot.HotSpotCallingConventionType; -import jdk.vm.ci.hotspot.HotSpotVMConfig; import jdk.vm.ci.meta.AllocatableValue; import jdk.vm.ci.meta.JavaKind; import jdk.vm.ci.meta.JavaType; @@ -73,8 +72,6 @@ private final Register[] allocatable; - private final int maxFrameSize; - /** * The caller saved registers always include all parameter registers. */ @@ -84,10 +81,6 @@ private final RegisterAttributes[] attributesMap; - public int getMaximumFrameSize() { - return maxFrameSize; - } - @Override public Register[] getAllocatableRegisters() { return allocatable.clone(); @@ -146,16 +139,15 @@ return registers; } - public AMD64HotSpotRegisterConfig(TargetDescription target, HotSpotVMConfig config) { - this(target, config, initAllocatable(target.arch, config.useCompressedOops)); + public AMD64HotSpotRegisterConfig(TargetDescription target, boolean useCompressedOops, boolean windowsOs) { + this(target, initAllocatable(target.arch, useCompressedOops), windowsOs); assert callerSaved.length >= allocatable.length; } - public AMD64HotSpotRegisterConfig(TargetDescription target, HotSpotVMConfig config, Register[] allocatable) { + public AMD64HotSpotRegisterConfig(TargetDescription target, Register[] allocatable, boolean windowsOs) { this.target = target; - this.maxFrameSize = config.maxFrameSize; - if (config.windowsOs) { + if (windowsOs) { javaGeneralParameterRegisters = new Register[]{rdx, r8, r9, rdi, rsi, rcx}; nativeGeneralParameterRegisters = new Register[]{rcx, rdx, r8, r9}; this.needsNativeStackHomeSpace = true; diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotVMConfig.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotVMConfig.java Thu Jun 16 16:41:50 2016 +0000 @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2016, 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.amd64; + +import jdk.vm.ci.hotspot.HotSpotVMConfigAccess; +import jdk.vm.ci.hotspot.HotSpotVMConfigStore; + +class AMD64HotSpotVMConfig extends HotSpotVMConfigAccess { + + AMD64HotSpotVMConfig(HotSpotVMConfigStore config) { + super(config); + } + + /** + * Maximum allowed size of allocated area for a frame. + */ + final int maxFrameSize = 16 * 1024; + + final boolean windowsOs = System.getProperty("os.name", "").startsWith("Windows"); + + final boolean useCountLeadingZerosInstruction = getFlag("UseCountLeadingZerosInstruction", Boolean.class); + final boolean useCountTrailingZerosInstruction = getFlag("UseCountTrailingZerosInstruction", Boolean.class); + final boolean useCompressedOops = getFlag("UseCompressedOops", Boolean.class); + + // CPU capabilities + final int useSSE = getFlag("UseSSE", Integer.class); + final int useAVX = getFlag("UseAVX", Integer.class); + + final long vmVersionFeatures = getFieldValue("Abstract_VM_Version::_features", Long.class, "uint64_t"); + + // CPU feature flags + 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); + final long amd64AVX512F = getConstant("VM_Version::CPU_AVX512F", Long.class); + final long amd64AVX512DQ = getConstant("VM_Version::CPU_AVX512DQ", Long.class); + final long amd64AVX512PF = getConstant("VM_Version::CPU_AVX512PF", Long.class); + final long amd64AVX512ER = getConstant("VM_Version::CPU_AVX512ER", Long.class); + final long amd64AVX512CD = getConstant("VM_Version::CPU_AVX512CD", Long.class); + final long amd64AVX512BW = getConstant("VM_Version::CPU_AVX512BW", Long.class); + final long amd64AVX512VL = getConstant("VM_Version::CPU_AVX512VL", Long.class); + final long amd64SHA = getConstant("VM_Version::CPU_SHA", Long.class); +} diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotJVMCIBackendFactory.java --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotJVMCIBackendFactory.java Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotJVMCIBackendFactory.java Thu Jun 16 16:41:50 2016 +0000 @@ -37,14 +37,13 @@ import jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider; import jdk.vm.ci.hotspot.HotSpotMetaAccessProvider; import jdk.vm.ci.hotspot.HotSpotStackIntrospection; -import jdk.vm.ci.hotspot.HotSpotVMConfig; import jdk.vm.ci.runtime.JVMCIBackend; import jdk.vm.ci.sparc.SPARC; import jdk.vm.ci.sparc.SPARC.CPUFeature; public class SPARCHotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFactory { - protected TargetDescription createTarget(HotSpotVMConfig config) { + protected TargetDescription createTarget(SPARCHotSpotVMConfig config) { final int stackFrameAlignment = 16; final int implicitNullCheckLimit = 4096; final boolean inlineObjects = false; @@ -56,7 +55,7 @@ return new HotSpotCodeCacheProvider(runtime, runtime.getConfig(), target, regConfig); } - protected EnumSet computeFeatures(HotSpotVMConfig config) { + protected EnumSet computeFeatures(SPARCHotSpotVMConfig config) { EnumSet features = EnumSet.noneOf(CPUFeature.class); if ((config.vmVersionFeatures & config.sparcVis1Instructions) != 0) { features.add(CPUFeature.VIS1); @@ -143,10 +142,11 @@ @SuppressWarnings("try") public JVMCIBackend createJVMCIBackend(HotSpotJVMCIRuntimeProvider runtime, JVMCIBackend host) { assert host == null; - TargetDescription target = createTarget(runtime.getConfig()); + SPARCHotSpotVMConfig config = new SPARCHotSpotVMConfig(runtime.getConfigStore()); + TargetDescription target = createTarget(config); HotSpotMetaAccessProvider metaAccess = new HotSpotMetaAccessProvider(runtime); - RegisterConfig regConfig = new SPARCHotSpotRegisterConfig(target, runtime.getConfig()); + RegisterConfig regConfig = new SPARCHotSpotRegisterConfig(target, config.useCompressedOops); HotSpotCodeCacheProvider codeCache = createCodeCache(runtime, target, regConfig); HotSpotConstantReflectionProvider constantReflection = new HotSpotConstantReflectionProvider(runtime); StackIntrospection stackIntrospection = new HotSpotStackIntrospection(runtime); diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotRegisterConfig.java --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotRegisterConfig.java Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotRegisterConfig.java Thu Jun 16 16:41:50 2016 +0000 @@ -81,7 +81,6 @@ import jdk.vm.ci.code.ValueKindFactory; import jdk.vm.ci.common.JVMCIError; import jdk.vm.ci.hotspot.HotSpotCallingConventionType; -import jdk.vm.ci.hotspot.HotSpotVMConfig; import jdk.vm.ci.meta.AllocatableValue; import jdk.vm.ci.meta.JavaKind; import jdk.vm.ci.meta.JavaType; @@ -167,14 +166,14 @@ return registers; } - public SPARCHotSpotRegisterConfig(TargetDescription target, HotSpotVMConfig config) { - this(target, initAllocatable(target.arch, config.useCompressedOops), config); + public SPARCHotSpotRegisterConfig(TargetDescription target, boolean useCompressedOops) { + this(target, initAllocatable(target.arch, useCompressedOops)); } - public SPARCHotSpotRegisterConfig(TargetDescription target, Register[] allocatable, HotSpotVMConfig config) { + public SPARCHotSpotRegisterConfig(TargetDescription target, Register[] allocatable) { this.target = target; this.allocatable = allocatable.clone(); - this.addNativeRegisterArgumentSlots = config.linuxOs; + this.addNativeRegisterArgumentSlots = false; HashSet callerSaveSet = new HashSet<>(); Collections.addAll(callerSaveSet, target.arch.getAvailableValueRegisters()); for (Register cs : calleeSaveRegisters) { diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotVMConfig.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotVMConfig.java Thu Jun 16 16:41:50 2016 +0000 @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2016, 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.sparc; + +import jdk.vm.ci.hotspot.HotSpotVMConfigAccess; +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. + */ +class SPARCHotSpotVMConfig extends HotSpotVMConfigAccess { + + SPARCHotSpotVMConfig(HotSpotVMConfigStore config) { + super(config); + } + + final boolean useCompressedOops = getFlag("UseCompressedOops", Boolean.class); + + // CPU capabilities + final long vmVersionFeatures = getFieldValue("Abstract_VM_Version::_features", Long.class, "uint64_t"); + + // SPARC specific values + 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); + + final boolean useBlockZeroing = getFlag("UseBlockZeroing", Boolean.class); + final int blockZeroingLowLimit = getFlag("BlockZeroingLowLimit", Integer.class); +} diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java Thu Jun 16 16:41:50 2016 +0000 @@ -35,11 +35,9 @@ import jdk.vm.ci.code.TargetDescription; import jdk.vm.ci.common.InitTimer; import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.hotspotvmconfig.HotSpotVMField; import jdk.vm.ci.meta.JavaType; import jdk.vm.ci.meta.ResolvedJavaMethod; import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.internal.misc.Unsafe; /** * Calls from Java into HotSpot. The behavior of all the methods in this class that take a native @@ -339,9 +337,22 @@ native void resetCompilationStatistics(); /** - * Initializes the fields of {@code config}. + * Reads the database of VM info. The return value encodes the info in a nested object array + * that is described by the pseudo Java object {@code info} below: + * + *
+     *     info = [
+     *         VMField[] vmFields,
+     *         [String name, Long size, ...] vmTypeSizes,
+     *         [String name, Long value, ...] vmConstants,
+     *         [String name, Long value, ...] vmAddresses,
+     *         VMFlag[] vmFlags
+     *     ]
+     * 
+ * + * @return VM info as encoded above */ - native long initializeConfiguration(HotSpotVMConfig config); + native Object[] readConfiguration(); /** * Resolves the implementation of {@code method} for virtual dispatches on objects of dynamic @@ -429,7 +440,6 @@ *
  • {@link HotSpotVMConfig#localVariableTableElementLengthOffset}
  • *
  • {@link HotSpotVMConfig#localVariableTableElementNameCpIndexOffset}
  • *
  • {@link HotSpotVMConfig#localVariableTableElementDescriptorCpIndexOffset}
  • - *
  • {@link HotSpotVMConfig#localVariableTableElementSignatureCpIndexOffset} *
  • {@link HotSpotVMConfig#localVariableTableElementSlotOffset} *
  • {@link HotSpotVMConfig#localVariableTableElementStartBciOffset} * diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCodeCacheProvider.java --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCodeCacheProvider.java Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCodeCacheProvider.java Thu Jun 16 16:41:50 2016 +0000 @@ -42,7 +42,7 @@ public class HotSpotCodeCacheProvider implements CodeCacheProvider { protected final HotSpotJVMCIRuntimeProvider runtime; - public final HotSpotVMConfig config; + protected final HotSpotVMConfig config; protected final TargetDescription target; protected final RegisterConfig regConfig; diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantReflectionProvider.java --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantReflectionProvider.java Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantReflectionProvider.java Thu Jun 16 16:41:50 2016 +0000 @@ -25,7 +25,6 @@ import java.lang.reflect.Array; import java.util.Objects; -import jdk.internal.vm.annotation.Stable; import jdk.vm.ci.common.JVMCIError; import jdk.vm.ci.meta.Constant; import jdk.vm.ci.meta.ConstantReflectionProvider; diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java Thu Jun 16 16:41:50 2016 +0000 @@ -22,8 +22,6 @@ */ package jdk.vm.ci.hotspot; -import java.lang.reflect.Module; - import jdk.vm.ci.code.CompilationRequest; import jdk.vm.ci.common.JVMCIError; import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option; @@ -68,7 +66,6 @@ if (compilerName != null) { for (JVMCICompilerFactory f : Services.load(JVMCICompilerFactory.class)) { if (f.getCompilerName().equals(compilerName)) { - Module jvmciModule = JVMCICompilerFactory.class.getModule(); Services.exportJVMCITo(f.getClass()); f.onSelection(); factory = f; diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java Thu Jun 16 16:41:50 2016 +0000 @@ -49,6 +49,7 @@ import jdk.vm.ci.common.JVMCIError; import jdk.vm.ci.hotspot.services.HotSpotJVMCICompilerFactory; import jdk.vm.ci.hotspot.services.HotSpotVMEventListener; +import jdk.vm.ci.hotspot.services.HotSpotJVMCICompilerFactory.CompilationLevel; import jdk.vm.ci.meta.JavaKind; import jdk.vm.ci.meta.JavaType; import jdk.vm.ci.meta.ResolvedJavaType; @@ -200,6 +201,7 @@ protected final CompilerToVM compilerToVm; + protected final HotSpotVMConfigStore configStore; protected final HotSpotVMConfig config; private final JVMCIBackend hostBackend; @@ -244,7 +246,8 @@ compilerToVm = new CompilerToVM(); try (InitTimer t = timer("HotSpotVMConfig")) { - config = new HotSpotVMConfig(compilerToVm); + configStore = new HotSpotVMConfigStore(compilerToVm); + config = new HotSpotVMConfig(configStore); } String hostArchitecture = config.getHostArchitectureName(); @@ -277,11 +280,24 @@ if (compilerFactory instanceof HotSpotJVMCICompilerFactory) { hsCompilerFactory = (HotSpotJVMCICompilerFactory) compilerFactory; trivialPrefixes = hsCompilerFactory.getTrivialPrefixes(); - compilationLevelAdjustment = hsCompilerFactory.getCompilationLevelAdjustment(config); + switch (hsCompilerFactory.getCompilationLevelAdjustment()) { + case None: + compilationLevelAdjustment = config.compLevelAdjustmentNone; + break; + case ByHolder: + compilationLevelAdjustment = config.compLevelAdjustmentByHolder; + break; + case ByFullSignature: + compilationLevelAdjustment = config.compLevelAdjustmentByFullSignature; + break; + default: + compilationLevelAdjustment = config.compLevelAdjustmentNone; + break; + } } else { hsCompilerFactory = null; trivialPrefixes = null; - compilationLevelAdjustment = 0; + compilationLevelAdjustment = config.compLevelAdjustmentNone; } } @@ -296,6 +312,10 @@ return metaAccessContext.fromClass(javaClass); } + public HotSpotVMConfigStore getConfigStore() { + return configStore; + } + public HotSpotVMConfig getConfig() { return config; } @@ -352,7 +372,35 @@ */ @SuppressWarnings({"unused"}) private int adjustCompilationLevel(Class declaringClass, String name, String signature, boolean isOsr, int level) { - return hsCompilerFactory.adjustCompilationLevel(config, declaringClass, name, signature, isOsr, level); + CompilationLevel curLevel; + if (level == config.compilationLevelNone) { + curLevel = CompilationLevel.None; + } else if (level == config.compilationLevelSimple) { + curLevel = CompilationLevel.Simple; + } else if (level == config.compilationLevelLimitedProfile) { + curLevel = CompilationLevel.LimitedProfile; + } else if (level == config.compilationLevelFullProfile) { + curLevel = CompilationLevel.FullProfile; + } else if (level == config.compilationLevelFullOptimization) { + curLevel = CompilationLevel.FullOptimization; + } else { + throw JVMCIError.shouldNotReachHere(); + } + + switch (hsCompilerFactory.adjustCompilationLevel(declaringClass, name, signature, isOsr, curLevel)) { + case None: + return config.compilationLevelNone; + case Simple: + return config.compilationLevelSimple; + case LimitedProfile: + return config.compilationLevelLimitedProfile; + case FullProfile: + return config.compilationLevelFullProfile; + case FullOptimization: + return config.compilationLevelFullOptimization; + default: + return level; + } } /** diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntimeProvider.java --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntimeProvider.java Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntimeProvider.java Thu Jun 16 16:41:50 2016 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -36,6 +36,8 @@ */ public interface HotSpotJVMCIRuntimeProvider extends JVMCIRuntime { + HotSpotVMConfigStore getConfigStore(); + HotSpotVMConfig getConfig(); CompilerToVM getCompilerToVM(); diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProvider.java --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProvider.java Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProvider.java Thu Jun 16 16:41:50 2016 +0000 @@ -22,7 +22,6 @@ */ package jdk.vm.ci.hotspot; -import jdk.vm.ci.hotspot.HotSpotVMConfig.CompressEncoding; import jdk.vm.ci.meta.Constant; import jdk.vm.ci.meta.JavaConstant; import jdk.vm.ci.meta.MemoryAccessProvider; @@ -32,11 +31,11 @@ */ public interface HotSpotMemoryAccessProvider extends MemoryAccessProvider { - JavaConstant readNarrowOopConstant(Constant base, long displacement, CompressEncoding encoding); + JavaConstant readNarrowOopConstant(Constant base, long displacement); Constant readKlassPointerConstant(Constant base, long displacement); - Constant readNarrowKlassPointerConstant(Constant base, long displacement, CompressEncoding encoding); + Constant readNarrowKlassPointerConstant(Constant base, long displacement); Constant readMethodPointerConstant(Constant base, long displacement); } diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java Thu Jun 16 16:41:50 2016 +0000 @@ -23,7 +23,7 @@ package jdk.vm.ci.hotspot; import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; -import jdk.vm.ci.hotspot.HotSpotVMConfig.CompressEncoding; + import jdk.vm.ci.meta.Constant; import jdk.vm.ci.meta.JavaConstant; import jdk.vm.ci.meta.JavaKind; @@ -206,8 +206,7 @@ } @Override - public JavaConstant readNarrowOopConstant(Constant base, long displacement, CompressEncoding encoding) { - assert encoding.equals(runtime.getConfig().getOopEncoding()) : "unexpected oop encoding: " + encoding + " != " + runtime.getConfig().getOopEncoding(); + public JavaConstant readNarrowOopConstant(Constant base, long displacement) { return HotSpotObjectConstantImpl.forObject(readRawObject(base, displacement, true), true); } @@ -227,7 +226,7 @@ } @Override - public Constant readNarrowKlassPointerConstant(Constant base, long displacement, CompressEncoding encoding) { + public Constant readNarrowKlassPointerConstant(Constant base, long displacement) { HotSpotResolvedObjectTypeImpl klass = readKlass(base, displacement, true); if (klass == null) { return HotSpotCompressedNullConstant.COMPRESSED_NULL; diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java Thu Jun 16 16:41:50 2016 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2016, 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 @@ -28,12 +28,8 @@ import java.lang.reflect.Field; import jdk.internal.vm.annotation.Stable; -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option; import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.MetaAccessProvider; import jdk.vm.ci.meta.ModifiersProvider; -import jdk.vm.ci.meta.ResolvedJavaField; import jdk.vm.ci.meta.ResolvedJavaType; /** diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java Thu Jun 16 16:41:50 2016 +0000 @@ -23,315 +23,32 @@ package jdk.vm.ci.hotspot; import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; -import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; - -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.util.HashMap; -import java.util.Iterator; - -import jdk.internal.misc.Unsafe; -import jdk.internal.vm.annotation.Stable; -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.hotspotvmconfig.HotSpotVMAddress; -import jdk.vm.ci.hotspotvmconfig.HotSpotVMConstant; -import jdk.vm.ci.hotspotvmconfig.HotSpotVMData; -import jdk.vm.ci.hotspotvmconfig.HotSpotVMField; -import jdk.vm.ci.hotspotvmconfig.HotSpotVMFlag; -import jdk.vm.ci.hotspotvmconfig.HotSpotVMType; /** * Used to access native configuration details. * * All non-static, public fields in this class are so that they can be compiled as constants. */ -public class HotSpotVMConfig { +class HotSpotVMConfig extends HotSpotVMConfigAccess { /** * Gets the configuration associated with the singleton {@link HotSpotJVMCIRuntime}. */ - public static HotSpotVMConfig config() { + static HotSpotVMConfig config() { return runtime().getConfig(); } - /** - * Maximum allowed size of allocated area for a frame. - */ - public final int maxFrameSize = 16 * 1024; - - public HotSpotVMConfig(CompilerToVM compilerToVm) { - // Get raw pointer to the array that contains all gHotSpotVM values. - final long gHotSpotVMData = compilerToVm.initializeConfiguration(this); - assert gHotSpotVMData != 0; - - // Make FindBugs happy. - jvmciHotSpotVMStructs = 0; - jvmciHotSpotVMTypes = 0; - jvmciHotSpotVMIntConstants = 0; - jvmciHotSpotVMLongConstants = 0; - jvmciHotSpotVMAddresses = 0; - - // Initialize the gHotSpotVM fields. - for (Field f : HotSpotVMConfig.class.getDeclaredFields()) { - if (f.isAnnotationPresent(HotSpotVMData.class)) { - HotSpotVMData annotation = f.getAnnotation(HotSpotVMData.class); - final int index = annotation.index(); - final long value = UNSAFE.getAddress(gHotSpotVMData + Unsafe.ADDRESS_SIZE * index); - try { - f.setLong(this, value); - } catch (IllegalAccessException e) { - throw new JVMCIError("index " + index, e); - } - } - } - - // Quick sanity check. - assert jvmciHotSpotVMStructs != 0; - assert jvmciHotSpotVMTypes != 0; - assert jvmciHotSpotVMIntConstants != 0; - assert jvmciHotSpotVMLongConstants != 0; - assert jvmciHotSpotVMAddresses != 0; - - initialize(); - - oopEncoding = new CompressEncoding(narrowOopBase, narrowOopShift, logMinObjAlignment()); - klassEncoding = new CompressEncoding(narrowKlassBase, narrowKlassShift, logKlassAlignment); - - assert check(); - assert HotSpotVMConfigVerifier.check(); - } - - @Override - public String toString() { - return getClass().getSimpleName(); - } - - /** - * Reads a {@code '\0'} terminated C string from native memory and converts it to a - * {@link String}. - * - * @return a Java string - */ - private 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(); - } - - /** - * Initialize fields by reading their values from vmStructs. - */ - private void initialize() { - // Fill the VM fields hash map. - HashMap vmFields = new HashMap<>(); - for (VMFields.Field e : new VMFields(jvmciHotSpotVMStructs)) { - vmFields.put(e.getName(), e); - } - - // Fill the VM types hash map. - HashMap vmTypes = new HashMap<>(); - for (VMTypes.Type e : new VMTypes(jvmciHotSpotVMTypes)) { - vmTypes.put(e.getTypeName(), e); - } - - // Fill the VM constants hash map. - HashMap vmConstants = new HashMap<>(); - for (AbstractConstant e : new VMIntConstants(jvmciHotSpotVMIntConstants)) { - vmConstants.put(e.getName(), e); - } - for (AbstractConstant e : new VMLongConstants(jvmciHotSpotVMLongConstants)) { - vmConstants.put(e.getName(), e); - } - - // Fill the VM addresses hash map. - HashMap vmAddresses = new HashMap<>(); - for (VMAddresses.Address e : new VMAddresses(jvmciHotSpotVMAddresses)) { - vmAddresses.put(e.getName(), e); - } - - // Fill the flags hash map. - HashMap flags = new HashMap<>(); - for (Flags.Flag e : new Flags(vmFields, vmTypes)) { - flags.put(e.getName(), e); - } - - String osName = getHostOSName(); - String osArch = getHostArchitectureName(); - - for (Field f : HotSpotVMConfig.class.getDeclaredFields()) { - if (f.isAnnotationPresent(HotSpotVMField.class)) { - HotSpotVMField annotation = f.getAnnotation(HotSpotVMField.class); - String name = annotation.name(); - String type = annotation.type(); - VMFields.Field entry = vmFields.get(name); - if (entry == null) { - if (!isRequired(osArch, annotation.archs())) { - continue; - } - throw new JVMCIError(f.getName() + ": expected VM field not found: " + name); - } - - // Make sure the native type is still the type we expect. - if (!type.isEmpty()) { - if (!type.equals(entry.getTypeString())) { - throw new JVMCIError(f.getName() + ": compiler expects type " + type + " but VM field " + name + " is of type " + entry.getTypeString()); - } - } + private final String osArch = getHostArchitectureName(); - switch (annotation.get()) { - case OFFSET: - setField(f, entry.getOffset()); - break; - case ADDRESS: - setField(f, entry.getAddress()); - break; - case VALUE: - setField(f, entry.getValue()); - break; - default: - throw new JVMCIError(f.getName() + ": unknown kind: " + annotation.get()); - } - } else if (f.isAnnotationPresent(HotSpotVMType.class)) { - HotSpotVMType annotation = f.getAnnotation(HotSpotVMType.class); - String name = annotation.name(); - VMTypes.Type entry = vmTypes.get(name); - if (entry == null) { - throw new JVMCIError(f.getName() + ": expected VM type not found: " + name); - } - - switch (annotation.get()) { - case SIZE: - setField(f, entry.getSize()); - break; - default: - throw new JVMCIError(f.getName() + ": unknown kind: " + annotation.get()); - } - } else if (f.isAnnotationPresent(HotSpotVMConstant.class)) { - HotSpotVMConstant annotation = f.getAnnotation(HotSpotVMConstant.class); - String name = annotation.name(); - AbstractConstant entry = vmConstants.get(name); - if (entry == null) { - if (!isRequired(osArch, annotation.archs())) { - continue; - } - throw new JVMCIError(f.getName() + ": expected VM constant not found: " + name); - } - setField(f, entry.getValue()); - } else if (f.isAnnotationPresent(HotSpotVMAddress.class)) { - HotSpotVMAddress annotation = f.getAnnotation(HotSpotVMAddress.class); - String name = annotation.name(); - VMAddresses.Address entry = vmAddresses.get(name); - if (entry == null) { - if (!isRequired(osName, annotation.os())) { - continue; - } - throw new JVMCIError(f.getName() + ": expected VM address not found: " + name); - } - setField(f, entry.getValue()); - } else if (f.isAnnotationPresent(HotSpotVMFlag.class)) { - HotSpotVMFlag annotation = f.getAnnotation(HotSpotVMFlag.class); - String name = annotation.name(); - Flags.Flag entry = flags.get(name); - if (entry == null) { - if (annotation.optional() || !isRequired(osArch, annotation.archs())) { - continue; - } - throw new JVMCIError(f.getName() + ": expected VM flag not found: " + name); - - } - setField(f, entry.getValue()); - } - } - } - - private final CompressEncoding oopEncoding; - private final CompressEncoding klassEncoding; - - public CompressEncoding getOopEncoding() { - return oopEncoding; - } - - public CompressEncoding getKlassEncoding() { - return klassEncoding; - } - - private void setField(Field field, Object value) { - try { - Class fieldType = field.getType(); - if (fieldType == boolean.class) { - if (value instanceof String) { - field.setBoolean(this, Boolean.valueOf((String) value)); - } else if (value instanceof Boolean) { - field.setBoolean(this, (boolean) value); - } else if (value instanceof Long) { - field.setBoolean(this, ((long) value) != 0); - } else { - throw new JVMCIError(value.getClass().getSimpleName()); - } - } else if (fieldType == byte.class) { - if (value instanceof Long) { - field.setByte(this, (byte) (long) value); - } else { - throw new JVMCIError(value.getClass().getSimpleName()); - } - } else if (fieldType == int.class) { - if (value instanceof Integer) { - field.setInt(this, (int) value); - } else if (value instanceof Long) { - field.setInt(this, (int) (long) value); - } else { - throw new JVMCIError(value.getClass().getSimpleName()); - } - } else if (fieldType == long.class) { - field.setLong(this, (long) value); - } else { - throw new JVMCIError(field.toString()); - } - } catch (IllegalAccessException e) { - throw new JVMCIError("%s: %s", field, e); - } - } - - /** - * Gets the host operating system name. - */ - private static String getHostOSName() { - String osName = System.getProperty("os.name"); - switch (osName) { - case "Linux": - osName = "linux"; - break; - case "SunOS": - osName = "solaris"; - break; - case "Mac OS X": - osName = "bsd"; - break; - default: - // Of course Windows is different... - if (osName.startsWith("Windows")) { - osName = "windows"; - } else { - throw new JVMCIError("Unexpected OS name: " + osName); - } - } - return osName; + HotSpotVMConfig(HotSpotVMConfigStore store) { + super(store); } /** * Gets the host architecture name for the purpose of finding the corresponding * {@linkplain HotSpotJVMCIBackendFactory backend}. */ - public String getHostArchitectureName() { + String getHostArchitectureName() { String arch = System.getProperty("os.arch"); switch (arch) { case "x86_64": @@ -344,1320 +61,256 @@ return arch; } - /** - * Determines if the current specification is included in a given set of specifications. - * - * @param current - * @param specification specifies a set of specifications, e.g. architectures or operating - * systems. A zero length value implies all. - */ - private static boolean isRequired(String current, String[] specification) { - if (specification.length == 0) { - return true; - } - for (String arch : specification) { - if (arch.equals(current)) { - return true; - } - } - return false; - } - - /** - * VMStructEntry (see {@code vmStructs.hpp}). - */ - @HotSpotVMData(index = 0) @Stable private long jvmciHotSpotVMStructs; - @HotSpotVMData(index = 1) @Stable private long jvmciHotSpotVMStructEntryTypeNameOffset; - @HotSpotVMData(index = 2) @Stable private long jvmciHotSpotVMStructEntryFieldNameOffset; - @HotSpotVMData(index = 3) @Stable private long jvmciHotSpotVMStructEntryTypeStringOffset; - @HotSpotVMData(index = 4) @Stable private long jvmciHotSpotVMStructEntryIsStaticOffset; - @HotSpotVMData(index = 5) @Stable private long jvmciHotSpotVMStructEntryOffsetOffset; - @HotSpotVMData(index = 6) @Stable private long jvmciHotSpotVMStructEntryAddressOffset; - @HotSpotVMData(index = 7) @Stable private long jvmciHotSpotVMStructEntryArrayStride; - - final class VMFields implements Iterable { - - private final long address; - - VMFields(long address) { - this.address = address; - } - - public Iterator iterator() { - return new Iterator() { - - private int index = 0; - - private Field current() { - return new Field(address + jvmciHotSpotVMStructEntryArrayStride * index); - } - - /** - * The last entry is identified by a NULL fieldName. - */ - public boolean hasNext() { - Field entry = current(); - return entry.getFieldName() != null; - } - - public Field next() { - Field entry = current(); - index++; - return entry; - } - }; - } - - final class Field { - - private final long entryAddress; - - Field(long address) { - this.entryAddress = address; - } - - public String getTypeName() { - long typeNameAddress = UNSAFE.getAddress(entryAddress + jvmciHotSpotVMStructEntryTypeNameOffset); - return readCString(UNSAFE, typeNameAddress); - } - - public String getFieldName() { - long fieldNameAddress = UNSAFE.getAddress(entryAddress + jvmciHotSpotVMStructEntryFieldNameOffset); - return readCString(UNSAFE, fieldNameAddress); - } - - public String getTypeString() { - long typeStringAddress = UNSAFE.getAddress(entryAddress + jvmciHotSpotVMStructEntryTypeStringOffset); - return readCString(UNSAFE, typeStringAddress); - } - - public boolean isStatic() { - return UNSAFE.getInt(entryAddress + jvmciHotSpotVMStructEntryIsStaticOffset) != 0; - } - - public long getOffset() { - return UNSAFE.getLong(entryAddress + jvmciHotSpotVMStructEntryOffsetOffset); - } - - public long getAddress() { - return UNSAFE.getAddress(entryAddress + jvmciHotSpotVMStructEntryAddressOffset); - } - - public String getName() { - String typeName = getTypeName(); - String fieldName = getFieldName(); - return typeName + "::" + fieldName; - } - - public long getValue() { - String type = getTypeString(); - switch (type) { - case "bool": - return UNSAFE.getByte(getAddress()); - case "int": - return UNSAFE.getInt(getAddress()); - case "uint64_t": - return UNSAFE.getLong(getAddress()); - case "address": - case "intptr_t": - case "uintptr_t": - case "size_t": - return UNSAFE.getAddress(getAddress()); - default: - // All foo* types are addresses. - if (type.endsWith("*")) { - return UNSAFE.getAddress(getAddress()); - } - throw new JVMCIError(type); - } - } - - @Override - public String toString() { - return String.format("Field[typeName=%s, fieldName=%s, typeString=%s, isStatic=%b, offset=%d, address=0x%x]", getTypeName(), getFieldName(), getTypeString(), isStatic(), getOffset(), - getAddress()); - } - } - } - - /** - * VMTypeEntry (see vmStructs.hpp). - */ - @HotSpotVMData(index = 8) @Stable private long jvmciHotSpotVMTypes; - @HotSpotVMData(index = 9) @Stable private long jvmciHotSpotVMTypeEntryTypeNameOffset; - @HotSpotVMData(index = 10) @Stable private long jvmciHotSpotVMTypeEntrySuperclassNameOffset; - @HotSpotVMData(index = 11) @Stable private long jvmciHotSpotVMTypeEntryIsOopTypeOffset; - @HotSpotVMData(index = 12) @Stable private long jvmciHotSpotVMTypeEntryIsIntegerTypeOffset; - @HotSpotVMData(index = 13) @Stable private long jvmciHotSpotVMTypeEntryIsUnsignedOffset; - @HotSpotVMData(index = 14) @Stable private long jvmciHotSpotVMTypeEntrySizeOffset; - @HotSpotVMData(index = 15) @Stable private long jvmciHotSpotVMTypeEntryArrayStride; - - final class VMTypes implements Iterable { - - private final long address; - - VMTypes(long address) { - this.address = address; - } - - public Iterator iterator() { - return new Iterator() { - - private int index = 0; + final boolean useDeferredInitBarriers = getFlag("ReduceInitialCardMarks", Boolean.class); - private Type current() { - return new Type(address + jvmciHotSpotVMTypeEntryArrayStride * index); - } - - /** - * The last entry is identified by a NULL type name. - */ - public boolean hasNext() { - Type entry = current(); - return entry.getTypeName() != null; - } - - public Type next() { - Type entry = current(); - index++; - return entry; - } - }; - } - - final class Type { - - private final long entryAddress; - - Type(long address) { - this.entryAddress = address; - } - - public String getTypeName() { - long typeNameAddress = UNSAFE.getAddress(entryAddress + jvmciHotSpotVMTypeEntryTypeNameOffset); - return readCString(UNSAFE, typeNameAddress); - } - - public String getSuperclassName() { - long superclassNameAddress = UNSAFE.getAddress(entryAddress + jvmciHotSpotVMTypeEntrySuperclassNameOffset); - return readCString(UNSAFE, superclassNameAddress); - } - - public boolean isOopType() { - return UNSAFE.getInt(entryAddress + jvmciHotSpotVMTypeEntryIsOopTypeOffset) != 0; - } - - public boolean isIntegerType() { - return UNSAFE.getInt(entryAddress + jvmciHotSpotVMTypeEntryIsIntegerTypeOffset) != 0; - } - - public boolean isUnsigned() { - return UNSAFE.getInt(entryAddress + jvmciHotSpotVMTypeEntryIsUnsignedOffset) != 0; - } - - public long getSize() { - return UNSAFE.getLong(entryAddress + jvmciHotSpotVMTypeEntrySizeOffset); - } - - @Override - public String toString() { - return String.format("Type[typeName=%s, superclassName=%s, isOopType=%b, isIntegerType=%b, isUnsigned=%b, size=%d]", getTypeName(), getSuperclassName(), isOopType(), isIntegerType(), - isUnsigned(), getSize()); - } - } - } - - public abstract class AbstractConstant { - - protected final long address; - protected final long nameOffset; - protected final long valueOffset; - - AbstractConstant(long address, long nameOffset, long valueOffset) { - this.address = address; - this.nameOffset = nameOffset; - this.valueOffset = valueOffset; - } - - public String getName() { - long nameAddress = UNSAFE.getAddress(address + nameOffset); - return readCString(UNSAFE, nameAddress); - } - - public abstract long getValue(); - } - - /** - * VMIntConstantEntry (see vmStructs.hpp). - */ - @HotSpotVMData(index = 16) @Stable private long jvmciHotSpotVMIntConstants; - @HotSpotVMData(index = 17) @Stable private long jvmciHotSpotVMIntConstantEntryNameOffset; - @HotSpotVMData(index = 18) @Stable private long jvmciHotSpotVMIntConstantEntryValueOffset; - @HotSpotVMData(index = 19) @Stable private long jvmciHotSpotVMIntConstantEntryArrayStride; - - final class VMIntConstants implements Iterable { - - private final long address; - - VMIntConstants(long address) { - this.address = address; - } - - public Iterator iterator() { - return new Iterator() { - - private int index = 0; - - private Constant current() { - return new Constant(address + jvmciHotSpotVMIntConstantEntryArrayStride * index); - } - - /** - * The last entry is identified by a NULL name. - */ - public boolean hasNext() { - Constant entry = current(); - return entry.getName() != null; - } - - public Constant next() { - Constant entry = current(); - index++; - return entry; - } - }; - } - - final class Constant extends AbstractConstant { - - Constant(long address) { - super(address, jvmciHotSpotVMIntConstantEntryNameOffset, jvmciHotSpotVMIntConstantEntryValueOffset); - } - - @Override - public long getValue() { - return UNSAFE.getInt(address + valueOffset); - } - - @Override - public String toString() { - return String.format("IntConstant[name=%s, value=%d (0x%x)]", getName(), getValue(), getValue()); - } - } - } - - /** - * VMLongConstantEntry (see vmStructs.hpp). - */ - @HotSpotVMData(index = 20) @Stable private long jvmciHotSpotVMLongConstants; - @HotSpotVMData(index = 21) @Stable private long jvmciHotSpotVMLongConstantEntryNameOffset; - @HotSpotVMData(index = 22) @Stable private long jvmciHotSpotVMLongConstantEntryValueOffset; - @HotSpotVMData(index = 23) @Stable private long jvmciHotSpotVMLongConstantEntryArrayStride; - - final class VMLongConstants implements Iterable { - - private final long address; - - VMLongConstants(long address) { - this.address = address; - } - - public Iterator iterator() { - return new Iterator() { - - private int index = 0; - - private Constant currentEntry() { - return new Constant(address + jvmciHotSpotVMLongConstantEntryArrayStride * index); - } + final boolean useCompressedOops = getFlag("UseCompressedOops", Boolean.class); - /** - * The last entry is identified by a NULL name. - */ - public boolean hasNext() { - Constant entry = currentEntry(); - return entry.getName() != null; - } - - public Constant next() { - Constant entry = currentEntry(); - index++; - return entry; - } - }; - } - - final class Constant extends AbstractConstant { - - Constant(long address) { - super(address, jvmciHotSpotVMLongConstantEntryNameOffset, jvmciHotSpotVMLongConstantEntryValueOffset); - } - - @Override - public long getValue() { - return UNSAFE.getLong(address + valueOffset); - } - - @Override - public String toString() { - return String.format("LongConstant[name=%s, value=%d (0x%x)]", getName(), getValue(), getValue()); - } - } - } - - /** - * VMAddressEntry (see vmStructs.hpp). - */ - @HotSpotVMData(index = 24) @Stable private long jvmciHotSpotVMAddresses; - @HotSpotVMData(index = 25) @Stable private long jvmciHotSpotVMAddressEntryNameOffset; - @HotSpotVMData(index = 26) @Stable private long jvmciHotSpotVMAddressEntryValueOffset; - @HotSpotVMData(index = 27) @Stable private long jvmciHotSpotVMAddressEntryArrayStride; - - final class VMAddresses implements Iterable { - - private final long address; - - VMAddresses(long address) { - this.address = address; - } - - public Iterator iterator() { - return new Iterator() { - - private int index = 0; - - private Address currentEntry() { - return new Address(address + jvmciHotSpotVMAddressEntryArrayStride * index); - } - - /** - * The last entry is identified by a NULL name. - */ - public boolean hasNext() { - Address entry = currentEntry(); - return entry.getName() != null; - } - - public Address next() { - Address entry = currentEntry(); - index++; - return entry; - } - }; - } - - final class Address extends AbstractConstant { - - Address(long address) { - super(address, jvmciHotSpotVMAddressEntryNameOffset, jvmciHotSpotVMAddressEntryValueOffset); - } - - @Override - public long getValue() { - return UNSAFE.getLong(address + valueOffset); - } - - @Override - public String toString() { - return String.format("Address[name=%s, value=%d (0x%x)]", getName(), getValue(), getValue()); - } - } - } - - final class Flags implements Iterable { - - private final long address; - private final long entrySize; - private final long typeOffset; - private final long nameOffset; - private final long addrOffset; - - Flags(HashMap vmStructs, HashMap vmTypes) { - address = vmStructs.get("Flag::flags").getValue(); - entrySize = vmTypes.get("Flag").getSize(); - typeOffset = vmStructs.get("Flag::_type").getOffset(); - nameOffset = vmStructs.get("Flag::_name").getOffset(); - addrOffset = vmStructs.get("Flag::_addr").getOffset(); - - assert vmTypes.get("bool").getSize() == Byte.BYTES; - assert vmTypes.get("intx").getSize() == Long.BYTES; - assert vmTypes.get("uintx").getSize() == Long.BYTES; - } - - public Iterator iterator() { - return new Iterator() { - - private int index = 0; - - private Flag current() { - return new Flag(address + entrySize * index); - } - - /** - * The last entry is identified by a NULL name. - */ - public boolean hasNext() { - Flag entry = current(); - return entry.getName() != null; - } - - public Flag next() { - Flag entry = current(); - index++; - return entry; - } - }; - } - - final class Flag { - - private final long entryAddress; - - Flag(long address) { - this.entryAddress = address; - } - - public String getType() { - long typeAddress = UNSAFE.getAddress(entryAddress + typeOffset); - return readCString(UNSAFE, typeAddress); - } - - public String getName() { - long nameAddress = UNSAFE.getAddress(entryAddress + nameOffset); - return readCString(UNSAFE, nameAddress); - } - - public long getAddr() { - return UNSAFE.getAddress(entryAddress + addrOffset); - } - - public Object getValue() { - switch (getType()) { - case "bool": - return Boolean.valueOf(UNSAFE.getByte(getAddr()) != 0); - case "intx": - case "uintx": - case "uint64_t": - return Long.valueOf(UNSAFE.getLong(getAddr())); - case "double": - return Double.valueOf(UNSAFE.getDouble(getAddr())); - case "ccstr": - case "ccstrlist": - return readCString(UNSAFE, getAddr()); - default: - throw new JVMCIError(getType()); - } - } - - @Override - public String toString() { - return String.format("Flag[type=%s, name=%s, value=%s]", getType(), getName(), getValue()); - } - } - } - - @HotSpotVMConstant(name = "ASSERT") @Stable public boolean cAssertions; - public final boolean windowsOs = System.getProperty("os.name", "").startsWith("Windows"); - public final boolean linuxOs = System.getProperty("os.name", "").startsWith("Linux"); - - @HotSpotVMFlag(name = "CodeEntryAlignment") @Stable public int codeEntryAlignment; - @HotSpotVMFlag(name = "VerifyOops") @Stable public boolean verifyOops; - @HotSpotVMFlag(name = "CITime") @Stable public boolean ciTime; - @HotSpotVMFlag(name = "CITimeEach") @Stable public boolean ciTimeEach; - @HotSpotVMFlag(name = "CompileTheWorldStartAt", optional = true) @Stable public int compileTheWorldStartAt; - @HotSpotVMFlag(name = "CompileTheWorldStopAt", optional = true) @Stable public int compileTheWorldStopAt; - @HotSpotVMFlag(name = "DontCompileHugeMethods") @Stable public boolean dontCompileHugeMethods; - @HotSpotVMFlag(name = "HugeMethodLimit") @Stable public int hugeMethodLimit; - @HotSpotVMFlag(name = "PrintInlining") @Stable public boolean printInlining; - @HotSpotVMFlag(name = "Inline") @Stable public boolean inline; - @HotSpotVMFlag(name = "JVMCIUseFastLocking") @Stable public boolean useFastLocking; - @HotSpotVMFlag(name = "ForceUnreachable") @Stable public boolean forceUnreachable; - @HotSpotVMFlag(name = "CodeCacheSegmentSize") @Stable public int codeSegmentSize; - @HotSpotVMFlag(name = "FoldStableValues") @Stable public boolean foldStableValues; - - @HotSpotVMFlag(name = "UseTLAB") @Stable public boolean useTLAB; - @HotSpotVMFlag(name = "UseBiasedLocking") @Stable public boolean useBiasedLocking; - @HotSpotVMFlag(name = "UsePopCountInstruction") @Stable public boolean usePopCountInstruction; - @HotSpotVMFlag(name = "UseCountLeadingZerosInstruction", archs = {"amd64"}) @Stable public boolean useCountLeadingZerosInstruction; - @HotSpotVMFlag(name = "UseCountTrailingZerosInstruction", archs = {"amd64"}) @Stable public boolean useCountTrailingZerosInstruction; - @HotSpotVMFlag(name = "UseAESIntrinsics") @Stable public boolean useAESIntrinsics; - @HotSpotVMFlag(name = "UseCRC32Intrinsics") @Stable public boolean useCRC32Intrinsics; - @HotSpotVMFlag(name = "UseG1GC") @Stable public boolean useG1GC; - @HotSpotVMFlag(name = "UseConcMarkSweepGC") @Stable public boolean useCMSGC; - - @HotSpotVMFlag(name = "AllocatePrefetchStyle") @Stable public int allocatePrefetchStyle; - @HotSpotVMFlag(name = "AllocatePrefetchInstr") @Stable public int allocatePrefetchInstr; - @HotSpotVMFlag(name = "AllocatePrefetchLines") @Stable public int allocatePrefetchLines; - @HotSpotVMFlag(name = "AllocateInstancePrefetchLines") @Stable public int allocateInstancePrefetchLines; - @HotSpotVMFlag(name = "AllocatePrefetchStepSize") @Stable public int allocatePrefetchStepSize; - @HotSpotVMFlag(name = "AllocatePrefetchDistance") @Stable public int allocatePrefetchDistance; - - @HotSpotVMFlag(name = "FlightRecorder", optional = true) @Stable public boolean flightRecorder; - - @HotSpotVMField(name = "CompilerToVM::Data::Universe_collectedHeap", type = "CollectedHeap*", get = HotSpotVMField.Type.VALUE) @Stable private long universeCollectedHeap; - @HotSpotVMField(name = "CollectedHeap::_total_collections", type = "unsigned int", get = HotSpotVMField.Type.OFFSET) @Stable private int collectedHeapTotalCollectionsOffset; - - public long gcTotalCollectionsAddress() { - return universeCollectedHeap + collectedHeapTotalCollectionsOffset; - } - - @HotSpotVMFlag(name = "ReduceInitialCardMarks") @Stable public boolean useDeferredInitBarriers; - - // Compressed Oops related values. - @HotSpotVMFlag(name = "UseCompressedOops") @Stable public boolean useCompressedOops; - @HotSpotVMFlag(name = "UseCompressedClassPointers") @Stable public boolean useCompressedClassPointers; - - @HotSpotVMField(name = "CompilerToVM::Data::Universe_narrow_oop_base", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long narrowOopBase; - @HotSpotVMField(name = "CompilerToVM::Data::Universe_narrow_oop_shift", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int narrowOopShift; - @HotSpotVMFlag(name = "ObjectAlignmentInBytes") @Stable public int objectAlignment; - - public final int minObjAlignment() { - return objectAlignment / heapWordSize; - } - - public final int logMinObjAlignment() { - return (int) (Math.log(objectAlignment) / Math.log(2)); - } - - @HotSpotVMType(name = "narrowKlass", get = HotSpotVMType.Type.SIZE) @Stable public int narrowKlassSize; - @HotSpotVMField(name = "CompilerToVM::Data::Universe_narrow_klass_base", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long narrowKlassBase; - @HotSpotVMField(name = "CompilerToVM::Data::Universe_narrow_klass_shift", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int narrowKlassShift; - @HotSpotVMConstant(name = "LogKlassAlignmentInBytes") @Stable public int logKlassAlignment; - - // CPU capabilities - @HotSpotVMFlag(name = "UseSSE") @Stable public int useSSE; - @HotSpotVMFlag(name = "UseAVX", archs = {"amd64"}) @Stable public int useAVX; - - @HotSpotVMField(name = "Abstract_VM_Version::_features", type = "uint64_t", get = HotSpotVMField.Type.VALUE) @Stable public long vmVersionFeatures; - - // AMD64 specific values - @HotSpotVMConstant(name = "VM_Version::CPU_CX8", archs = {"amd64"}) @Stable public long amd64CX8; - @HotSpotVMConstant(name = "VM_Version::CPU_CMOV", archs = {"amd64"}) @Stable public long amd64CMOV; - @HotSpotVMConstant(name = "VM_Version::CPU_FXSR", archs = {"amd64"}) @Stable public long amd64FXSR; - @HotSpotVMConstant(name = "VM_Version::CPU_HT", archs = {"amd64"}) @Stable public long amd64HT; - @HotSpotVMConstant(name = "VM_Version::CPU_MMX", archs = {"amd64"}) @Stable public long amd64MMX; - @HotSpotVMConstant(name = "VM_Version::CPU_3DNOW_PREFETCH", archs = {"amd64"}) @Stable public long amd643DNOWPREFETCH; - @HotSpotVMConstant(name = "VM_Version::CPU_SSE", archs = {"amd64"}) @Stable public long amd64SSE; - @HotSpotVMConstant(name = "VM_Version::CPU_SSE2", archs = {"amd64"}) @Stable public long amd64SSE2; - @HotSpotVMConstant(name = "VM_Version::CPU_SSE3", archs = {"amd64"}) @Stable public long amd64SSE3; - @HotSpotVMConstant(name = "VM_Version::CPU_SSSE3", archs = {"amd64"}) @Stable public long amd64SSSE3; - @HotSpotVMConstant(name = "VM_Version::CPU_SSE4A", archs = {"amd64"}) @Stable public long amd64SSE4A; - @HotSpotVMConstant(name = "VM_Version::CPU_SSE4_1", archs = {"amd64"}) @Stable public long amd64SSE41; - @HotSpotVMConstant(name = "VM_Version::CPU_SSE4_2", archs = {"amd64"}) @Stable public long amd64SSE42; - @HotSpotVMConstant(name = "VM_Version::CPU_POPCNT", archs = {"amd64"}) @Stable public long amd64POPCNT; - @HotSpotVMConstant(name = "VM_Version::CPU_LZCNT", archs = {"amd64"}) @Stable public long amd64LZCNT; - @HotSpotVMConstant(name = "VM_Version::CPU_TSC", archs = {"amd64"}) @Stable public long amd64TSC; - @HotSpotVMConstant(name = "VM_Version::CPU_TSCINV", archs = {"amd64"}) @Stable public long amd64TSCINV; - @HotSpotVMConstant(name = "VM_Version::CPU_AVX", archs = {"amd64"}) @Stable public long amd64AVX; - @HotSpotVMConstant(name = "VM_Version::CPU_AVX2", archs = {"amd64"}) @Stable public long amd64AVX2; - @HotSpotVMConstant(name = "VM_Version::CPU_AES", archs = {"amd64"}) @Stable public long amd64AES; - @HotSpotVMConstant(name = "VM_Version::CPU_ERMS", archs = {"amd64"}) @Stable public long amd64ERMS; - @HotSpotVMConstant(name = "VM_Version::CPU_CLMUL", archs = {"amd64"}) @Stable public long amd64CLMUL; - @HotSpotVMConstant(name = "VM_Version::CPU_BMI1", archs = {"amd64"}) @Stable public long amd64BMI1; - @HotSpotVMConstant(name = "VM_Version::CPU_BMI2", archs = {"amd64"}) @Stable public long amd64BMI2; - @HotSpotVMConstant(name = "VM_Version::CPU_RTM", archs = {"amd64"}) @Stable public long amd64RTM; - @HotSpotVMConstant(name = "VM_Version::CPU_ADX", archs = {"amd64"}) @Stable public long amd64ADX; - @HotSpotVMConstant(name = "VM_Version::CPU_AVX512F", archs = {"amd64"}) @Stable public long amd64AVX512F; - @HotSpotVMConstant(name = "VM_Version::CPU_AVX512DQ", archs = {"amd64"}) @Stable public long amd64AVX512DQ; - @HotSpotVMConstant(name = "VM_Version::CPU_AVX512PF", archs = {"amd64"}) @Stable public long amd64AVX512PF; - @HotSpotVMConstant(name = "VM_Version::CPU_AVX512ER", archs = {"amd64"}) @Stable public long amd64AVX512ER; - @HotSpotVMConstant(name = "VM_Version::CPU_AVX512CD", archs = {"amd64"}) @Stable public long amd64AVX512CD; - @HotSpotVMConstant(name = "VM_Version::CPU_AVX512BW", archs = {"amd64"}) @Stable public long amd64AVX512BW; - @HotSpotVMConstant(name = "VM_Version::CPU_AVX512VL", archs = {"amd64"}) @Stable public long amd64AVX512VL; - @HotSpotVMConstant(name = "VM_Version::CPU_SHA", archs = {"amd64"}) @Stable public long amd64SHA; - - // SPARC specific values - @HotSpotVMConstant(name = "VM_Version::vis3_instructions_m", archs = {"sparc"}) @Stable public int sparcVis3Instructions; - @HotSpotVMConstant(name = "VM_Version::vis2_instructions_m", archs = {"sparc"}) @Stable public int sparcVis2Instructions; - @HotSpotVMConstant(name = "VM_Version::vis1_instructions_m", archs = {"sparc"}) @Stable public int sparcVis1Instructions; - @HotSpotVMConstant(name = "VM_Version::cbcond_instructions_m", archs = {"sparc"}) @Stable public int sparcCbcondInstructions; - @HotSpotVMConstant(name = "VM_Version::v8_instructions_m", archs = {"sparc"}) @Stable public int sparcV8Instructions; - @HotSpotVMConstant(name = "VM_Version::hardware_mul32_m", archs = {"sparc"}) @Stable public int sparcHardwareMul32; - @HotSpotVMConstant(name = "VM_Version::hardware_div32_m", archs = {"sparc"}) @Stable public int sparcHardwareDiv32; - @HotSpotVMConstant(name = "VM_Version::hardware_fsmuld_m", archs = {"sparc"}) @Stable public int sparcHardwareFsmuld; - @HotSpotVMConstant(name = "VM_Version::hardware_popc_m", archs = {"sparc"}) @Stable public int sparcHardwarePopc; - @HotSpotVMConstant(name = "VM_Version::v9_instructions_m", archs = {"sparc"}) @Stable public int sparcV9Instructions; - @HotSpotVMConstant(name = "VM_Version::sun4v_m", archs = {"sparc"}) @Stable public int sparcSun4v; - @HotSpotVMConstant(name = "VM_Version::blk_init_instructions_m", archs = {"sparc"}) @Stable public int sparcBlkInitInstructions; - @HotSpotVMConstant(name = "VM_Version::fmaf_instructions_m", archs = {"sparc"}) @Stable public int sparcFmafInstructions; - @HotSpotVMConstant(name = "VM_Version::fmau_instructions_m", archs = {"sparc"}) @Stable public int sparcFmauInstructions; - @HotSpotVMConstant(name = "VM_Version::sparc64_family_m", archs = {"sparc"}) @Stable public int sparcSparc64Family; - @HotSpotVMConstant(name = "VM_Version::M_family_m", archs = {"sparc"}) @Stable public int sparcMFamily; - @HotSpotVMConstant(name = "VM_Version::T_family_m", archs = {"sparc"}) @Stable public int sparcTFamily; - @HotSpotVMConstant(name = "VM_Version::T1_model_m", archs = {"sparc"}) @Stable public int sparcT1Model; - @HotSpotVMConstant(name = "VM_Version::sparc5_instructions_m", archs = {"sparc"}) @Stable public int sparcSparc5Instructions; - @HotSpotVMConstant(name = "VM_Version::aes_instructions_m", archs = {"sparc"}) @Stable public int sparcAesInstructions; - @HotSpotVMConstant(name = "VM_Version::sha1_instruction_m", archs = {"sparc"}) @Stable public int sparcSha1Instruction; - @HotSpotVMConstant(name = "VM_Version::sha256_instruction_m", archs = {"sparc"}) @Stable public int sparcSha256Instruction; - @HotSpotVMConstant(name = "VM_Version::sha512_instruction_m", archs = {"sparc"}) @Stable public int sparcSha512Instruction; - - @HotSpotVMFlag(name = "UseBlockZeroing", archs = {"sparc"}) @Stable public boolean useBlockZeroing; - @HotSpotVMFlag(name = "BlockZeroingLowLimit", archs = {"sparc"}) @Stable public int blockZeroingLowLimit; - - @HotSpotVMFlag(name = "StackShadowPages") @Stable public int stackShadowPages; - @HotSpotVMFlag(name = "StackReservedPages") @Stable public int stackReservedPages; - @HotSpotVMFlag(name = "UseStackBanging") @Stable public boolean useStackBanging; - @HotSpotVMConstant(name = "STACK_BIAS") @Stable public int stackBias; - @HotSpotVMField(name = "CompilerToVM::Data::vm_page_size", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int vmPageSize; - - // offsets, ... - @HotSpotVMField(name = "oopDesc::_mark", type = "markOop", get = HotSpotVMField.Type.OFFSET) @Stable public int markOffset; - @HotSpotVMField(name = "oopDesc::_metadata._klass", type = "Klass*", get = HotSpotVMField.Type.OFFSET) @Stable public int hubOffset; - - @HotSpotVMField(name = "Klass::_prototype_header", type = "markOop", get = HotSpotVMField.Type.OFFSET) @Stable public int prototypeMarkWordOffset; - @HotSpotVMField(name = "Klass::_subklass", type = "Klass*", get = HotSpotVMField.Type.OFFSET) @Stable public int subklassOffset; - @HotSpotVMField(name = "Klass::_next_sibling", type = "Klass*", get = HotSpotVMField.Type.OFFSET) @Stable public int nextSiblingOffset; - @HotSpotVMField(name = "Klass::_super_check_offset", type = "juint", get = HotSpotVMField.Type.OFFSET) @Stable public int superCheckOffsetOffset; - @HotSpotVMField(name = "Klass::_secondary_super_cache", type = "Klass*", get = HotSpotVMField.Type.OFFSET) @Stable public int secondarySuperCacheOffset; - @HotSpotVMField(name = "Klass::_secondary_supers", type = "Array*", get = HotSpotVMField.Type.OFFSET) @Stable public int secondarySupersOffset; + final int prototypeMarkWordOffset = getFieldOffset("Klass::_prototype_header", Integer.class, "markOop"); + final int subklassOffset = getFieldOffset("Klass::_subklass", Integer.class, "Klass*"); + final int nextSiblingOffset = getFieldOffset("Klass::_next_sibling", Integer.class, "Klass*"); + final int superCheckOffsetOffset = getFieldOffset("Klass::_super_check_offset", Integer.class, "juint"); + final int secondarySuperCacheOffset = getFieldOffset("Klass::_secondary_super_cache", Integer.class, "Klass*"); /** * The offset of the _java_mirror field (of type {@link Class}) in a Klass. */ - @HotSpotVMField(name = "Klass::_java_mirror", type = "oop", get = HotSpotVMField.Type.OFFSET) @Stable public int classMirrorOffset; + final int classMirrorOffset = getFieldOffset("Klass::_java_mirror", Integer.class, "oop"); - @HotSpotVMField(name = "Klass::_super", type = "Klass*", get = HotSpotVMField.Type.OFFSET) @Stable public int klassSuperKlassOffset; - @HotSpotVMField(name = "Klass::_modifier_flags", type = "jint", get = HotSpotVMField.Type.OFFSET) @Stable public int klassModifierFlagsOffset; - @HotSpotVMField(name = "Klass::_access_flags", type = "AccessFlags", get = HotSpotVMField.Type.OFFSET) @Stable public int klassAccessFlagsOffset; - @HotSpotVMField(name = "Klass::_layout_helper", type = "jint", get = HotSpotVMField.Type.OFFSET) @Stable public int klassLayoutHelperOffset; - @HotSpotVMField(name = "Klass::_name", type = "Symbol*", get = HotSpotVMField.Type.OFFSET) @Stable public int klassNameOffset; + final int klassAccessFlagsOffset = getFieldOffset("Klass::_access_flags", Integer.class, "AccessFlags"); + final int klassLayoutHelperOffset = getFieldOffset("Klass::_layout_helper", Integer.class, "jint"); + + final int klassLayoutHelperNeutralValue = getConstant("Klass::_lh_neutral_value", Integer.class); + final int klassLayoutHelperInstanceSlowPathBit = getConstant("Klass::_lh_instance_slow_path_bit", Integer.class); - @HotSpotVMConstant(name = "Klass::_lh_neutral_value") @Stable public int klassLayoutHelperNeutralValue; - @HotSpotVMConstant(name = "Klass::_lh_instance_slow_path_bit") @Stable public int klassLayoutHelperInstanceSlowPathBit; - @HotSpotVMConstant(name = "Klass::_lh_log2_element_size_shift") @Stable public int layoutHelperLog2ElementSizeShift; - @HotSpotVMConstant(name = "Klass::_lh_log2_element_size_mask") @Stable public int layoutHelperLog2ElementSizeMask; - @HotSpotVMConstant(name = "Klass::_lh_element_type_shift") @Stable public int layoutHelperElementTypeShift; - @HotSpotVMConstant(name = "Klass::_lh_element_type_mask") @Stable public int layoutHelperElementTypeMask; - @HotSpotVMConstant(name = "Klass::_lh_header_size_shift") @Stable public int layoutHelperHeaderSizeShift; - @HotSpotVMConstant(name = "Klass::_lh_header_size_mask") @Stable public int layoutHelperHeaderSizeMask; - @HotSpotVMConstant(name = "Klass::_lh_array_tag_shift") @Stable public int layoutHelperArrayTagShift; - @HotSpotVMConstant(name = "Klass::_lh_array_tag_type_value") @Stable public int layoutHelperArrayTagTypeValue; - @HotSpotVMConstant(name = "Klass::_lh_array_tag_obj_value") @Stable public int layoutHelperArrayTagObjectValue; + final int vtableEntrySize = getTypeSize("vtableEntry"); + final int vtableEntryMethodOffset = getFieldOffset("vtableEntry::_method", Integer.class, "Method*"); - /** - * This filters out the bit that differentiates a type array from an object array. - */ - public int layoutHelperElementTypePrimitiveInPlace() { - return (layoutHelperArrayTagTypeValue & ~layoutHelperArrayTagObjectValue) << layoutHelperArrayTagShift; - } - - /** - * Bit pattern in the klass layout helper that can be used to identify arrays. - */ - public final int arrayKlassLayoutHelperIdentifier = 0x80000000; - - @HotSpotVMType(name = "vtableEntry", get = HotSpotVMType.Type.SIZE) @Stable public int vtableEntrySize; - @HotSpotVMField(name = "vtableEntry::_method", type = "Method*", get = HotSpotVMField.Type.OFFSET) @Stable public int vtableEntryMethodOffset; + final int instanceKlassSourceFileNameIndexOffset = getFieldOffset("InstanceKlass::_source_file_name_index", Integer.class, "u2"); + final int instanceKlassInitStateOffset = getFieldOffset("InstanceKlass::_init_state", Integer.class, "u1"); + final int instanceKlassConstantsOffset = getFieldOffset("InstanceKlass::_constants", Integer.class, "ConstantPool*"); + final int instanceKlassFieldsOffset = getFieldOffset("InstanceKlass::_fields", Integer.class, "Array*"); + final int klassVtableStartOffset = getFieldValue("CompilerToVM::Data::Klass_vtable_start_offset", Integer.class, "int"); + final int klassVtableLengthOffset = getFieldValue("CompilerToVM::Data::Klass_vtable_length_offset", Integer.class, "int"); - @HotSpotVMType(name = "InstanceKlass", get = HotSpotVMType.Type.SIZE) @Stable public int instanceKlassSize; - @HotSpotVMField(name = "InstanceKlass::_source_file_name_index", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int instanceKlassSourceFileNameIndexOffset; - @HotSpotVMField(name = "InstanceKlass::_init_state", type = "u1", get = HotSpotVMField.Type.OFFSET) @Stable public int instanceKlassInitStateOffset; - @HotSpotVMField(name = "InstanceKlass::_constants", type = "ConstantPool*", get = HotSpotVMField.Type.OFFSET) @Stable public int instanceKlassConstantsOffset; - @HotSpotVMField(name = "InstanceKlass::_fields", type = "Array*", get = HotSpotVMField.Type.OFFSET) @Stable public int instanceKlassFieldsOffset; - @HotSpotVMField(name = "CompilerToVM::Data::Klass_vtable_start_offset", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int klassVtableStartOffset; - @HotSpotVMField(name = "CompilerToVM::Data::Klass_vtable_length_offset", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int klassVtableLengthOffset; - - @HotSpotVMConstant(name = "InstanceKlass::linked") @Stable public int instanceKlassStateLinked; - @HotSpotVMConstant(name = "InstanceKlass::fully_initialized") @Stable public int instanceKlassStateFullyInitialized; + final int instanceKlassStateLinked = getConstant("InstanceKlass::linked", Integer.class); + final int instanceKlassStateFullyInitialized = getConstant("InstanceKlass::fully_initialized", Integer.class); - @HotSpotVMType(name = "arrayOopDesc", get = HotSpotVMType.Type.SIZE) @Stable public int arrayOopDescSize; - - /** - * The offset of the array length word in an array object's header. - * - * See {@code arrayOopDesc::length_offset_in_bytes()}. - */ - public final int arrayOopDescLengthOffset() { - return useCompressedClassPointers ? hubOffset + narrowKlassSize : arrayOopDescSize; - } + final int arrayU1LengthOffset = getFieldOffset("Array::_length", Integer.class, "int"); + final int arrayU1DataOffset = getFieldOffset("Array::_data", Integer.class); + final int arrayU2DataOffset = getFieldOffset("Array::_data", Integer.class); - @HotSpotVMField(name = "Array::_length", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int arrayU1LengthOffset; - @HotSpotVMField(name = "Array::_data", type = "", get = HotSpotVMField.Type.OFFSET) @Stable public int arrayU1DataOffset; - @HotSpotVMField(name = "Array::_data", type = "", get = HotSpotVMField.Type.OFFSET) @Stable public int arrayU2DataOffset; - @HotSpotVMField(name = "Array::_length", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int metaspaceArrayLengthOffset; - @HotSpotVMField(name = "Array::_data[0]", type = "Klass*", get = HotSpotVMField.Type.OFFSET) @Stable public int metaspaceArrayBaseOffset; - - @HotSpotVMField(name = "ObjArrayKlass::_element_klass", type = "Klass*", get = HotSpotVMField.Type.OFFSET) @Stable public int arrayClassElementOffset; + final int fieldInfoAccessFlagsOffset = getConstant("FieldInfo::access_flags_offset", Integer.class); + final int fieldInfoNameIndexOffset = getConstant("FieldInfo::name_index_offset", Integer.class); + final int fieldInfoSignatureIndexOffset = getConstant("FieldInfo::signature_index_offset", Integer.class); + final int fieldInfoLowPackedOffset = getConstant("FieldInfo::low_packed_offset", Integer.class); + final int fieldInfoHighPackedOffset = getConstant("FieldInfo::high_packed_offset", Integer.class); + final int fieldInfoFieldSlots = getConstant("FieldInfo::field_slots", Integer.class); - @HotSpotVMConstant(name = "FieldInfo::access_flags_offset") @Stable public int fieldInfoAccessFlagsOffset; - @HotSpotVMConstant(name = "FieldInfo::name_index_offset") @Stable public int fieldInfoNameIndexOffset; - @HotSpotVMConstant(name = "FieldInfo::signature_index_offset") @Stable public int fieldInfoSignatureIndexOffset; - @HotSpotVMConstant(name = "FieldInfo::initval_index_offset") @Stable public int fieldInfoInitvalIndexOffset; - @HotSpotVMConstant(name = "FieldInfo::low_packed_offset") @Stable public int fieldInfoLowPackedOffset; - @HotSpotVMConstant(name = "FieldInfo::high_packed_offset") @Stable public int fieldInfoHighPackedOffset; - @HotSpotVMConstant(name = "FieldInfo::field_slots") @Stable public int fieldInfoFieldSlots; + final int fieldInfoTagSize = getConstant("FIELDINFO_TAG_SIZE", Integer.class); - @HotSpotVMConstant(name = "FIELDINFO_TAG_SIZE") @Stable public int fieldInfoTagSize; - - @HotSpotVMConstant(name = "JVM_ACC_MONITOR_MATCH") @Stable public int jvmAccMonitorMatch; - @HotSpotVMConstant(name = "JVM_ACC_HAS_MONITOR_BYTECODES") @Stable public int jvmAccHasMonitorBytecodes; - @HotSpotVMConstant(name = "JVM_ACC_HAS_FINALIZER") @Stable public int jvmAccHasFinalizer; - @HotSpotVMConstant(name = "JVM_ACC_FIELD_INTERNAL") @Stable public int jvmAccFieldInternal; - @HotSpotVMConstant(name = "JVM_ACC_FIELD_STABLE") @Stable public int jvmAccFieldStable; - @HotSpotVMConstant(name = "JVM_ACC_FIELD_HAS_GENERIC_SIGNATURE") @Stable public int jvmAccFieldHasGenericSignature; - @HotSpotVMConstant(name = "JVM_ACC_WRITTEN_FLAGS") @Stable public int jvmAccWrittenFlags; - @HotSpotVMConstant(name = "JVM_ACC_IS_CLONEABLE_FAST") @Stable public int jvmAccIsCloneableFast; + final int jvmAccHasFinalizer = getConstant("JVM_ACC_HAS_FINALIZER", Integer.class); + final int jvmAccFieldInternal = getConstant("JVM_ACC_FIELD_INTERNAL", Integer.class); + final int jvmAccFieldStable = getConstant("JVM_ACC_FIELD_STABLE", Integer.class); + final int jvmAccFieldHasGenericSignature = getConstant("JVM_ACC_FIELD_HAS_GENERIC_SIGNATURE", Integer.class); + final int jvmAccIsCloneableFast = getConstant("JVM_ACC_IS_CLONEABLE_FAST", Integer.class); // Modifier.SYNTHETIC is not public so we get it via vmStructs. - @HotSpotVMConstant(name = "JVM_ACC_SYNTHETIC") @Stable public int jvmAccSynthetic; - - /** - * @see HotSpotResolvedObjectTypeImpl#createField - */ - @HotSpotVMConstant(name = "JVM_RECOGNIZED_FIELD_MODIFIERS") @Stable public int recognizedFieldModifiers; - - @HotSpotVMField(name = "Thread::_tlab", type = "ThreadLocalAllocBuffer", get = HotSpotVMField.Type.OFFSET) @Stable public int threadTlabOffset; - - @HotSpotVMField(name = "JavaThread::_anchor", type = "JavaFrameAnchor", get = HotSpotVMField.Type.OFFSET) @Stable public int javaThreadAnchorOffset; - @HotSpotVMField(name = "JavaThread::_threadObj", type = "oop", get = HotSpotVMField.Type.OFFSET) @Stable public int threadObjectOffset; - @HotSpotVMField(name = "JavaThread::_osthread", type = "OSThread*", get = HotSpotVMField.Type.OFFSET) @Stable public int osThreadOffset; - @HotSpotVMField(name = "JavaThread::_dirty_card_queue", type = "DirtyCardQueue", get = HotSpotVMField.Type.OFFSET) @Stable public int javaThreadDirtyCardQueueOffset; - @HotSpotVMField(name = "JavaThread::_is_method_handle_return", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int threadIsMethodHandleReturnOffset; - @HotSpotVMField(name = "JavaThread::_satb_mark_queue", type = "SATBMarkQueue", get = HotSpotVMField.Type.OFFSET) @Stable public int javaThreadSatbMarkQueueOffset; - @HotSpotVMField(name = "JavaThread::_vm_result", type = "oop", get = HotSpotVMField.Type.OFFSET) @Stable public int threadObjectResultOffset; - @HotSpotVMField(name = "JavaThread::_jvmci_counters", type = "jlong*", get = HotSpotVMField.Type.OFFSET) @Stable public int jvmciCountersThreadOffset; - @HotSpotVMField(name = "JavaThread::_reserved_stack_activation", type = "address", get = HotSpotVMField.Type.OFFSET) @Stable public int javaThreadReservedStackActivationOffset; - - /** - * An invalid value for {@link #rtldDefault}. - */ - public static final long INVALID_RTLD_DEFAULT_HANDLE = 0xDEADFACE; - - /** - * Address of the library lookup routine. The C signature of this routine is: - * - *
    -     *     void* (const char *filename, char *ebuf, int ebuflen)
    -     * 
    - */ - @HotSpotVMAddress(name = "os::dll_load") @Stable public long dllLoad; - - /** - * Address of the library lookup routine. The C signature of this routine is: - * - *
    -     *     void* (void* handle, const char* name)
    -     * 
    - */ - @HotSpotVMAddress(name = "os::dll_lookup") @Stable public long dllLookup; - - /** - * A pseudo-handle which when used as the first argument to {@link #dllLookup} means lookup will - * return the first occurrence of the desired symbol using the default library search order. If - * this field is {@value #INVALID_RTLD_DEFAULT_HANDLE}, then this capability is not supported on - * the current platform. - */ - @HotSpotVMAddress(name = "RTLD_DEFAULT", os = {"bsd", "linux"}) @Stable public long rtldDefault = INVALID_RTLD_DEFAULT_HANDLE; - - /** - * This field is used to pass exception objects into and out of the runtime system during - * exception handling for compiled code. - */ - @HotSpotVMField(name = "JavaThread::_exception_oop", type = "oop", get = HotSpotVMField.Type.OFFSET) @Stable public int threadExceptionOopOffset; - @HotSpotVMField(name = "JavaThread::_exception_pc", type = "address", get = HotSpotVMField.Type.OFFSET) @Stable public int threadExceptionPcOffset; - @HotSpotVMField(name = "ThreadShadow::_pending_exception", type = "oop", get = HotSpotVMField.Type.OFFSET) @Stable public int pendingExceptionOffset; + final int jvmAccSynthetic = getConstant("JVM_ACC_SYNTHETIC", Integer.class); - @HotSpotVMField(name = "JavaThread::_pending_deoptimization", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int pendingDeoptimizationOffset; - @HotSpotVMField(name = "JavaThread::_pending_failed_speculation", type = "oop", get = HotSpotVMField.Type.OFFSET) @Stable public int pendingFailedSpeculationOffset; - @HotSpotVMField(name = "JavaThread::_pending_transfer_to_interpreter", type = "bool", get = HotSpotVMField.Type.OFFSET) @Stable public int pendingTransferToInterpreterOffset; - - @HotSpotVMField(name = "JavaFrameAnchor::_last_Java_sp", type = "intptr_t*", get = HotSpotVMField.Type.OFFSET) @Stable private int javaFrameAnchorLastJavaSpOffset; - @HotSpotVMField(name = "JavaFrameAnchor::_last_Java_pc", type = "address", get = HotSpotVMField.Type.OFFSET) @Stable private int javaFrameAnchorLastJavaPcOffset; - @HotSpotVMField(name = "JavaFrameAnchor::_last_Java_fp", type = "intptr_t*", get = HotSpotVMField.Type.OFFSET, archs = {"aarch64, amd64"}) @Stable private int javaFrameAnchorLastJavaFpOffset; - @HotSpotVMField(name = "JavaFrameAnchor::_flags", type = "int", get = HotSpotVMField.Type.OFFSET, archs = {"sparc"}) @Stable private int javaFrameAnchorFlagsOffset; - - public int threadLastJavaSpOffset() { - return javaThreadAnchorOffset + javaFrameAnchorLastJavaSpOffset; - } - - public int threadLastJavaPcOffset() { - return javaThreadAnchorOffset + javaFrameAnchorLastJavaPcOffset; - } - - public int threadLastJavaFpOffset() { - assert getHostArchitectureName().equals("aarch64") || getHostArchitectureName().equals("amd64"); - return javaThreadAnchorOffset + javaFrameAnchorLastJavaFpOffset; - } + // This is only valid on AMD64. + final int runtimeCallStackSize = getConstant("frame::arg_reg_save_area_bytes", Integer.class, osArch.equals("amd64") ? null : 0); - /** - * This value is only valid on SPARC. - */ - public int threadJavaFrameAnchorFlagsOffset() { - // TODO add an assert for SPARC - return javaThreadAnchorOffset + javaFrameAnchorFlagsOffset; - } - - // These are only valid on AMD64. - @HotSpotVMConstant(name = "frame::arg_reg_save_area_bytes", archs = {"amd64"}) @Stable public int runtimeCallStackSize; - @HotSpotVMConstant(name = "frame::interpreter_frame_sender_sp_offset", archs = {"amd64"}) @Stable public int frameInterpreterFrameSenderSpOffset; - @HotSpotVMConstant(name = "frame::interpreter_frame_last_sp_offset", archs = {"amd64"}) @Stable public int frameInterpreterFrameLastSpOffset; - - @HotSpotVMConstant(name = "dirtyCardQueueBufferOffset") @Stable private int dirtyCardQueueBufferOffset; - @HotSpotVMConstant(name = "dirtyCardQueueIndexOffset") @Stable private int dirtyCardQueueIndexOffset; - - @HotSpotVMConstant(name = "satbMarkQueueBufferOffset") @Stable private int satbMarkQueueBufferOffset; - @HotSpotVMConstant(name = "satbMarkQueueIndexOffset") @Stable private int satbMarkQueueIndexOffset; - @HotSpotVMConstant(name = "satbMarkQueueActiveOffset") @Stable private int satbMarkQueueActiveOffset; - - @HotSpotVMField(name = "OSThread::_interrupted", type = "jint", get = HotSpotVMField.Type.OFFSET) @Stable public int osThreadInterruptedOffset; - - @HotSpotVMConstant(name = "markOopDesc::hash_shift") @Stable public long markOopDescHashShift; - - @HotSpotVMConstant(name = "markOopDesc::biased_lock_mask_in_place") @Stable public int biasedLockMaskInPlace; - @HotSpotVMConstant(name = "markOopDesc::age_mask_in_place") @Stable public int ageMaskInPlace; - @HotSpotVMConstant(name = "markOopDesc::epoch_mask_in_place") @Stable public int epochMaskInPlace; - @HotSpotVMConstant(name = "markOopDesc::hash_mask") @Stable public long markOopDescHashMask; - @HotSpotVMConstant(name = "markOopDesc::hash_mask_in_place") @Stable public long markOopDescHashMaskInPlace; - - @HotSpotVMConstant(name = "markOopDesc::unlocked_value") @Stable public int unlockedMask; - @HotSpotVMConstant(name = "markOopDesc::biased_lock_pattern") @Stable public int biasedLockPattern; - - @HotSpotVMConstant(name = "markOopDesc::no_hash_in_place") @Stable public int markWordNoHashInPlace; - @HotSpotVMConstant(name = "markOopDesc::no_lock_in_place") @Stable public int markWordNoLockInPlace; + private final int markWordNoHashInPlace = getConstant("markOopDesc::no_hash_in_place", Integer.class); + private final int markWordNoLockInPlace = getConstant("markOopDesc::no_lock_in_place", Integer.class); /** * See {@code markOopDesc::prototype()}. */ - public long arrayPrototypeMarkWord() { + long arrayPrototypeMarkWord() { return markWordNoHashInPlace | markWordNoLockInPlace; } - /** - * See {@code markOopDesc::copy_set_hash()}. - */ - public long tlabIntArrayMarkWord() { - long tmp = arrayPrototypeMarkWord() & (~markOopDescHashMaskInPlace); - tmp |= ((0x2 & markOopDescHashMask) << markOopDescHashShift); - return tmp; - } + final int methodAccessFlagsOffset = getFieldOffset("Method::_access_flags", Integer.class, "AccessFlags"); + final int methodConstMethodOffset = getFieldOffset("Method::_constMethod", Integer.class, "ConstMethod*"); + final int methodIntrinsicIdOffset = getFieldOffset("Method::_intrinsic_id", Integer.class, "u2"); + final int methodFlagsOffset = getFieldOffset("Method::_flags", Integer.class, "u2"); + final int methodVtableIndexOffset = getFieldOffset("Method::_vtable_index", Integer.class, "int"); - /** - * Mark word right shift to get identity hash code. - */ - @HotSpotVMConstant(name = "markOopDesc::hash_shift") @Stable public int identityHashCodeShift; + final int methodDataOffset = getFieldOffset("Method::_method_data", Integer.class, "MethodData*"); + final int methodCodeOffset = getFieldOffset("Method::_code", Integer.class, "CompiledMethod*"); - /** - * Identity hash code value when uninitialized. - */ - @HotSpotVMConstant(name = "markOopDesc::no_hash") @Stable public int uninitializedIdentityHashCodeValue; + final int methodFlagsCallerSensitive = getConstant("Method::_caller_sensitive", Integer.class); + final int methodFlagsForceInline = getConstant("Method::_force_inline", Integer.class); + final int methodFlagsDontInline = getConstant("Method::_dont_inline", Integer.class); + final int methodFlagsReservedStackAccess = getConstant("Method::_reserved_stack_access", Integer.class); + final int nonvirtualVtableIndex = getConstant("Method::nonvirtual_vtable_index", Integer.class); + final int invalidVtableIndex = getConstant("Method::invalid_vtable_index", Integer.class); - @HotSpotVMField(name = "Method::_access_flags", type = "AccessFlags", get = HotSpotVMField.Type.OFFSET) @Stable public int methodAccessFlagsOffset; - @HotSpotVMField(name = "Method::_constMethod", type = "ConstMethod*", get = HotSpotVMField.Type.OFFSET) @Stable public int methodConstMethodOffset; - @HotSpotVMField(name = "Method::_intrinsic_id", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int methodIntrinsicIdOffset; - @HotSpotVMField(name = "Method::_flags", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int methodFlagsOffset; - @HotSpotVMField(name = "Method::_vtable_index", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int methodVtableIndexOffset; + final int methodDataSize = getFieldOffset("MethodData::_size", Integer.class, "int"); + final int methodDataDataSize = getFieldOffset("MethodData::_data_size", Integer.class, "int"); + final int methodDataOopDataOffset = getFieldOffset("MethodData::_data[0]", Integer.class, "intptr_t"); + final int methodDataOopTrapHistoryOffset = getFieldOffset("MethodData::_trap_hist._array[0]", Integer.class, "u1"); + final int methodDataIRSizeOffset = getFieldOffset("MethodData::_jvmci_ir_size", Integer.class, "int"); - @HotSpotVMField(name = "Method::_method_counters", type = "MethodCounters*", get = HotSpotVMField.Type.OFFSET) @Stable public int methodCountersOffset; - @HotSpotVMField(name = "Method::_method_data", type = "MethodData*", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataOffset; - @HotSpotVMField(name = "Method::_from_compiled_entry", type = "address", get = HotSpotVMField.Type.OFFSET) @Stable public int methodCompiledEntryOffset; - @HotSpotVMField(name = "Method::_code", type = "CompiledMethod*", get = HotSpotVMField.Type.OFFSET) @Stable public int methodCodeOffset; + final int nmethodCompLevelOffset = getFieldOffset("nmethod::_comp_level", Integer.class, "int"); - @HotSpotVMConstant(name = "Method::_jfr_towrite") @Stable public int methodFlagsJfrTowrite; - @HotSpotVMConstant(name = "Method::_caller_sensitive") @Stable public int methodFlagsCallerSensitive; - @HotSpotVMConstant(name = "Method::_force_inline") @Stable public int methodFlagsForceInline; - @HotSpotVMConstant(name = "Method::_dont_inline") @Stable public int methodFlagsDontInline; - @HotSpotVMConstant(name = "Method::_hidden") @Stable public int methodFlagsHidden; - @HotSpotVMConstant(name = "Method::_reserved_stack_access") @Stable public int methodFlagsReservedStackAccess; - @HotSpotVMConstant(name = "Method::nonvirtual_vtable_index") @Stable public int nonvirtualVtableIndex; - @HotSpotVMConstant(name = "Method::invalid_vtable_index") @Stable public int invalidVtableIndex; + final int compilationLevelNone = getConstant("CompLevel_none", Integer.class); + final int compilationLevelSimple = getConstant("CompLevel_simple", Integer.class); + final int compilationLevelLimitedProfile = getConstant("CompLevel_limited_profile", Integer.class); + final int compilationLevelFullProfile = getConstant("CompLevel_full_profile", Integer.class); + final int compilationLevelFullOptimization = getConstant("CompLevel_full_optimization", Integer.class); - @HotSpotVMField(name = "MethodCounters::_invocation_counter", type = "InvocationCounter", get = HotSpotVMField.Type.OFFSET) @Stable public int invocationCounterOffset; - @HotSpotVMField(name = "MethodCounters::_backedge_counter", type = "InvocationCounter", get = HotSpotVMField.Type.OFFSET) @Stable public int backedgeCounterOffset; - @HotSpotVMConstant(name = "InvocationCounter::count_increment") @Stable public int invocationCounterIncrement; - @HotSpotVMConstant(name = "InvocationCounter::count_shift") @Stable public int invocationCounterShift; + final int compLevelAdjustmentNone = getConstant("JVMCIRuntime::none", Integer.class); + final int compLevelAdjustmentByHolder = getConstant("JVMCIRuntime::by_holder", Integer.class); + final int compLevelAdjustmentByFullSignature = getConstant("JVMCIRuntime::by_full_signature", Integer.class); - @HotSpotVMField(name = "MethodData::_size", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataSize; - @HotSpotVMField(name = "MethodData::_data_size", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataDataSize; - @HotSpotVMField(name = "MethodData::_data[0]", type = "intptr_t", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataOopDataOffset; - @HotSpotVMField(name = "MethodData::_trap_hist._array[0]", type = "u1", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataOopTrapHistoryOffset; - @HotSpotVMField(name = "MethodData::_jvmci_ir_size", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataIRSizeOffset; + final int invocationEntryBci = getConstant("InvocationEntryBci", Integer.class); - @HotSpotVMField(name = "nmethod::_verified_entry_point", type = "address", get = HotSpotVMField.Type.OFFSET) @Stable public int nmethodEntryOffset; - @HotSpotVMField(name = "nmethod::_comp_level", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int nmethodCompLevelOffset; - - @HotSpotVMConstant(name = "CompLevel_none") @Stable public int compilationLevelNone; - @HotSpotVMConstant(name = "CompLevel_simple") @Stable public int compilationLevelSimple; - @HotSpotVMConstant(name = "CompLevel_limited_profile") @Stable public int compilationLevelLimitedProfile; - @HotSpotVMConstant(name = "CompLevel_full_profile") @Stable public int compilationLevelFullProfile; - @HotSpotVMConstant(name = "CompLevel_full_optimization") @Stable public int compilationLevelFullOptimization; + final int extraStackEntries = getFieldValue("CompilerToVM::Data::Method_extra_stack_entries", Integer.class, "int"); - @HotSpotVMConstant(name = "JVMCIRuntime::none") @Stable public int compLevelAdjustmentNone; - @HotSpotVMConstant(name = "JVMCIRuntime::by_holder") @Stable public int compLevelAdjustmentByHolder; - @HotSpotVMConstant(name = "JVMCIRuntime::by_full_signature") @Stable public int compLevelAdjustmentByFullSignature; - - @HotSpotVMConstant(name = "InvocationEntryBci") @Stable public int invocationEntryBci; + final int constMethodConstantsOffset = getFieldOffset("ConstMethod::_constants", Integer.class, "ConstantPool*"); + final int constMethodFlagsOffset = getFieldOffset("ConstMethod::_flags", Integer.class, "u2"); + final int constMethodCodeSizeOffset = getFieldOffset("ConstMethod::_code_size", Integer.class, "u2"); + final int constMethodNameIndexOffset = getFieldOffset("ConstMethod::_name_index", Integer.class, "u2"); + final int constMethodSignatureIndexOffset = getFieldOffset("ConstMethod::_signature_index", Integer.class, "u2"); + final int constMethodMaxStackOffset = getFieldOffset("ConstMethod::_max_stack", Integer.class, "u2"); + final int methodMaxLocalsOffset = getFieldOffset("ConstMethod::_max_locals", Integer.class, "u2"); - @HotSpotVMField(name = "JVMCIEnv::_task", type = "CompileTask*", get = HotSpotVMField.Type.OFFSET) @Stable public int jvmciEnvTaskOffset; - @HotSpotVMField(name = "JVMCIEnv::_jvmti_can_hotswap_or_post_breakpoint", type = "bool", get = HotSpotVMField.Type.OFFSET) @Stable public int jvmciEnvJvmtiCanHotswapOrPostBreakpointOffset; - @HotSpotVMField(name = "CompileTask::_num_inlined_bytecodes", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int compileTaskNumInlinedBytecodesOffset; - - @HotSpotVMField(name = "CompilerToVM::Data::Method_extra_stack_entries", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int extraStackEntries; + final int constMethodHasLineNumberTable = getConstant("ConstMethod::_has_linenumber_table", Integer.class); + final int constMethodHasLocalVariableTable = getConstant("ConstMethod::_has_localvariable_table", Integer.class); + final int constMethodHasExceptionTable = getConstant("ConstMethod::_has_exception_table", Integer.class); - @HotSpotVMField(name = "ConstMethod::_constants", type = "ConstantPool*", get = HotSpotVMField.Type.OFFSET) @Stable public int constMethodConstantsOffset; - @HotSpotVMField(name = "ConstMethod::_flags", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int constMethodFlagsOffset; - @HotSpotVMField(name = "ConstMethod::_code_size", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int constMethodCodeSizeOffset; - @HotSpotVMField(name = "ConstMethod::_name_index", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int constMethodNameIndexOffset; - @HotSpotVMField(name = "ConstMethod::_signature_index", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int constMethodSignatureIndexOffset; - @HotSpotVMField(name = "ConstMethod::_max_stack", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int constMethodMaxStackOffset; - @HotSpotVMField(name = "ConstMethod::_max_locals", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int methodMaxLocalsOffset; - - @HotSpotVMConstant(name = "ConstMethod::_has_linenumber_table") @Stable public int constMethodHasLineNumberTable; - @HotSpotVMConstant(name = "ConstMethod::_has_localvariable_table") @Stable public int constMethodHasLocalVariableTable; - @HotSpotVMConstant(name = "ConstMethod::_has_exception_table") @Stable public int constMethodHasExceptionTable; + final int exceptionTableElementSize = getTypeSize("ExceptionTableElement"); + final int exceptionTableElementStartPcOffset = getFieldOffset("ExceptionTableElement::start_pc", Integer.class, "u2"); + final int exceptionTableElementEndPcOffset = getFieldOffset("ExceptionTableElement::end_pc", Integer.class, "u2"); + final int exceptionTableElementHandlerPcOffset = getFieldOffset("ExceptionTableElement::handler_pc", Integer.class, "u2"); + final int exceptionTableElementCatchTypeIndexOffset = getFieldOffset("ExceptionTableElement::catch_type_index", Integer.class, "u2"); - @HotSpotVMType(name = "ExceptionTableElement", get = HotSpotVMType.Type.SIZE) @Stable public int exceptionTableElementSize; - @HotSpotVMField(name = "ExceptionTableElement::start_pc", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int exceptionTableElementStartPcOffset; - @HotSpotVMField(name = "ExceptionTableElement::end_pc", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int exceptionTableElementEndPcOffset; - @HotSpotVMField(name = "ExceptionTableElement::handler_pc", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int exceptionTableElementHandlerPcOffset; - @HotSpotVMField(name = "ExceptionTableElement::catch_type_index", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int exceptionTableElementCatchTypeIndexOffset; + final int localVariableTableElementSize = getTypeSize("LocalVariableTableElement"); + final int localVariableTableElementStartBciOffset = getFieldOffset("LocalVariableTableElement::start_bci", Integer.class, "u2"); + final int localVariableTableElementLengthOffset = getFieldOffset("LocalVariableTableElement::length", Integer.class, "u2"); + final int localVariableTableElementNameCpIndexOffset = getFieldOffset("LocalVariableTableElement::name_cp_index", Integer.class, "u2"); + final int localVariableTableElementDescriptorCpIndexOffset = getFieldOffset("LocalVariableTableElement::descriptor_cp_index", Integer.class, "u2"); + final int localVariableTableElementSlotOffset = getFieldOffset("LocalVariableTableElement::slot", Integer.class, "u2"); - @HotSpotVMType(name = "LocalVariableTableElement", get = HotSpotVMType.Type.SIZE) @Stable public int localVariableTableElementSize; - @HotSpotVMField(name = "LocalVariableTableElement::start_bci", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int localVariableTableElementStartBciOffset; - @HotSpotVMField(name = "LocalVariableTableElement::length", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int localVariableTableElementLengthOffset; - @HotSpotVMField(name = "LocalVariableTableElement::name_cp_index", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int localVariableTableElementNameCpIndexOffset; - @HotSpotVMField(name = "LocalVariableTableElement::descriptor_cp_index", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int localVariableTableElementDescriptorCpIndexOffset; - @HotSpotVMField(name = "LocalVariableTableElement::signature_cp_index", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int localVariableTableElementSignatureCpIndexOffset; - @HotSpotVMField(name = "LocalVariableTableElement::slot", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int localVariableTableElementSlotOffset; + final int constantPoolSize = getTypeSize("ConstantPool"); + final int constantPoolTagsOffset = getFieldOffset("ConstantPool::_tags", Integer.class, "Array*"); + final int constantPoolHolderOffset = getFieldOffset("ConstantPool::_pool_holder", Integer.class, "InstanceKlass*"); + final int constantPoolLengthOffset = getFieldOffset("ConstantPool::_length", Integer.class, "int"); - @HotSpotVMType(name = "ConstantPool", get = HotSpotVMType.Type.SIZE) @Stable public int constantPoolSize; - @HotSpotVMField(name = "ConstantPool::_tags", type = "Array*", get = HotSpotVMField.Type.OFFSET) @Stable public int constantPoolTagsOffset; - @HotSpotVMField(name = "ConstantPool::_pool_holder", type = "InstanceKlass*", get = HotSpotVMField.Type.OFFSET) @Stable public int constantPoolHolderOffset; - @HotSpotVMField(name = "ConstantPool::_length", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int constantPoolLengthOffset; - - @HotSpotVMConstant(name = "ConstantPool::CPCACHE_INDEX_TAG") @Stable public int constantPoolCpCacheIndexTag; + final int constantPoolCpCacheIndexTag = getConstant("ConstantPool::CPCACHE_INDEX_TAG", Integer.class); - @HotSpotVMConstant(name = "JVM_CONSTANT_Utf8") @Stable public int jvmConstantUtf8; - @HotSpotVMConstant(name = "JVM_CONSTANT_Integer") @Stable public int jvmConstantInteger; - @HotSpotVMConstant(name = "JVM_CONSTANT_Long") @Stable public int jvmConstantLong; - @HotSpotVMConstant(name = "JVM_CONSTANT_Float") @Stable public int jvmConstantFloat; - @HotSpotVMConstant(name = "JVM_CONSTANT_Double") @Stable public int jvmConstantDouble; - @HotSpotVMConstant(name = "JVM_CONSTANT_Class") @Stable public int jvmConstantClass; - @HotSpotVMConstant(name = "JVM_CONSTANT_UnresolvedClass") @Stable public int jvmConstantUnresolvedClass; - @HotSpotVMConstant(name = "JVM_CONSTANT_UnresolvedClassInError") @Stable public int jvmConstantUnresolvedClassInError; - @HotSpotVMConstant(name = "JVM_CONSTANT_String") @Stable public int jvmConstantString; - @HotSpotVMConstant(name = "JVM_CONSTANT_Fieldref") @Stable public int jvmConstantFieldref; - @HotSpotVMConstant(name = "JVM_CONSTANT_Methodref") @Stable public int jvmConstantMethodref; - @HotSpotVMConstant(name = "JVM_CONSTANT_InterfaceMethodref") @Stable public int jvmConstantInterfaceMethodref; - @HotSpotVMConstant(name = "JVM_CONSTANT_NameAndType") @Stable public int jvmConstantNameAndType; - @HotSpotVMConstant(name = "JVM_CONSTANT_MethodHandle") @Stable public int jvmConstantMethodHandle; - @HotSpotVMConstant(name = "JVM_CONSTANT_MethodHandleInError") @Stable public int jvmConstantMethodHandleInError; - @HotSpotVMConstant(name = "JVM_CONSTANT_MethodType") @Stable public int jvmConstantMethodType; - @HotSpotVMConstant(name = "JVM_CONSTANT_MethodTypeInError") @Stable public int jvmConstantMethodTypeInError; - @HotSpotVMConstant(name = "JVM_CONSTANT_InvokeDynamic") @Stable public int jvmConstantInvokeDynamic; + final int jvmConstantUtf8 = getConstant("JVM_CONSTANT_Utf8", Integer.class); + final int jvmConstantInteger = getConstant("JVM_CONSTANT_Integer", Integer.class); + final int jvmConstantLong = getConstant("JVM_CONSTANT_Long", Integer.class); + final int jvmConstantFloat = getConstant("JVM_CONSTANT_Float", Integer.class); + final int jvmConstantDouble = getConstant("JVM_CONSTANT_Double", Integer.class); + final int jvmConstantClass = getConstant("JVM_CONSTANT_Class", Integer.class); + final int jvmConstantUnresolvedClass = getConstant("JVM_CONSTANT_UnresolvedClass", Integer.class); + final int jvmConstantUnresolvedClassInError = getConstant("JVM_CONSTANT_UnresolvedClassInError", Integer.class); + final int jvmConstantString = getConstant("JVM_CONSTANT_String", Integer.class); + final int jvmConstantFieldref = getConstant("JVM_CONSTANT_Fieldref", Integer.class); + final int jvmConstantMethodref = getConstant("JVM_CONSTANT_Methodref", Integer.class); + final int jvmConstantInterfaceMethodref = getConstant("JVM_CONSTANT_InterfaceMethodref", Integer.class); + final int jvmConstantNameAndType = getConstant("JVM_CONSTANT_NameAndType", Integer.class); + final int jvmConstantMethodHandle = getConstant("JVM_CONSTANT_MethodHandle", Integer.class); + final int jvmConstantMethodHandleInError = getConstant("JVM_CONSTANT_MethodHandleInError", Integer.class); + final int jvmConstantMethodType = getConstant("JVM_CONSTANT_MethodType", Integer.class); + final int jvmConstantMethodTypeInError = getConstant("JVM_CONSTANT_MethodTypeInError", Integer.class); + final int jvmConstantInvokeDynamic = getConstant("JVM_CONSTANT_InvokeDynamic", Integer.class); - @HotSpotVMConstant(name = "JVM_CONSTANT_ExternalMax") @Stable public int jvmConstantExternalMax; - @HotSpotVMConstant(name = "JVM_CONSTANT_InternalMin") @Stable public int jvmConstantInternalMin; - @HotSpotVMConstant(name = "JVM_CONSTANT_InternalMax") @Stable public int jvmConstantInternalMax; - - @HotSpotVMConstant(name = "HeapWordSize") @Stable public int heapWordSize; + final int jvmConstantExternalMax = getConstant("JVM_CONSTANT_ExternalMax", Integer.class); + final int jvmConstantInternalMin = getConstant("JVM_CONSTANT_InternalMin", Integer.class); + final int jvmConstantInternalMax = getConstant("JVM_CONSTANT_InternalMax", Integer.class); - @HotSpotVMType(name = "Symbol*", get = HotSpotVMType.Type.SIZE) @Stable public int symbolPointerSize; + final int heapWordSize = getConstant("HeapWordSize", Integer.class); - @HotSpotVMField(name = "vmSymbols::_symbols[0]", type = "Symbol*", get = HotSpotVMField.Type.ADDRESS) @Stable public long vmSymbolsSymbols; - @HotSpotVMConstant(name = "vmSymbols::FIRST_SID") @Stable public int vmSymbolsFirstSID; - @HotSpotVMConstant(name = "vmSymbols::SID_LIMIT") @Stable public int vmSymbolsSIDLimit; + final int symbolPointerSize = getTypeSize("Symbol*"); - /** - * Bit pattern that represents a non-oop. Neither the high bits nor the low bits of this value - * are allowed to look like (respectively) the high or low bits of a real oop. - */ - @HotSpotVMField(name = "CompilerToVM::Data::Universe_non_oop_bits", type = "void*", get = HotSpotVMField.Type.VALUE) @Stable public long nonOopBits; + final long vmSymbolsSymbols = getFieldAddress("vmSymbols::_symbols[0]", "Symbol*"); + final int vmSymbolsFirstSID = getConstant("vmSymbols::FIRST_SID", Integer.class); + final int vmSymbolsSIDLimit = getConstant("vmSymbols::SID_LIMIT", Integer.class); - @HotSpotVMField(name = "StubRoutines::_verify_oop_count", type = "jint", get = HotSpotVMField.Type.ADDRESS) @Stable public long verifyOopCounterAddress; - @HotSpotVMField(name = "CompilerToVM::Data::Universe_verify_oop_mask", type = "uintptr_t", get = HotSpotVMField.Type.VALUE) @Stable public long verifyOopMask; - @HotSpotVMField(name = "CompilerToVM::Data::Universe_verify_oop_bits", type = "uintptr_t", get = HotSpotVMField.Type.VALUE) @Stable public long verifyOopBits; - @HotSpotVMField(name = "CompilerToVM::Data::Universe_base_vtable_size", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int universeBaseVtableSize; + final int universeBaseVtableSize = getFieldValue("CompilerToVM::Data::Universe_base_vtable_size", Integer.class, "int"); - public final int baseVtableLength() { + final int baseVtableLength() { return universeBaseVtableSize / vtableEntrySize; } - @HotSpotVMField(name = "HeapRegion::LogOfHRGrainBytes", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int logOfHRGrainBytes; - - @HotSpotVMConstant(name = "CardTableModRefBS::dirty_card") @Stable public byte dirtyCardValue; - @HotSpotVMConstant(name = "G1SATBCardTableModRefBS::g1_young_gen") @Stable public byte g1YoungCardValue; - - @HotSpotVMField(name = "CompilerToVM::Data::cardtable_start_address", type = "jbyte*", get = HotSpotVMField.Type.VALUE) @Stable private long cardtableStartAddress; - @HotSpotVMField(name = "CompilerToVM::Data::cardtable_shift", type = "int", get = HotSpotVMField.Type.VALUE) @Stable private int cardtableShift; - - public long cardtableStartAddress() { - return cardtableStartAddress; - } - - public int cardtableShift() { - return cardtableShift; - } - - @HotSpotVMField(name = "os::_polling_page", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long safepointPollingAddress; - - // G1 Collector Related Values. - - public int g1CardQueueIndexOffset() { - return javaThreadDirtyCardQueueOffset + dirtyCardQueueIndexOffset; - } - - public int g1CardQueueBufferOffset() { - return javaThreadDirtyCardQueueOffset + dirtyCardQueueBufferOffset; - } - - public int g1SATBQueueMarkingOffset() { - return javaThreadSatbMarkQueueOffset + satbMarkQueueActiveOffset; - } - - public int g1SATBQueueIndexOffset() { - return javaThreadSatbMarkQueueOffset + satbMarkQueueIndexOffset; - } - - public int g1SATBQueueBufferOffset() { - return javaThreadSatbMarkQueueOffset + satbMarkQueueBufferOffset; - } - - @HotSpotVMField(name = "java_lang_Class::_klass_offset", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int klassOffset; - @HotSpotVMField(name = "java_lang_Class::_array_klass_offset", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int arrayKlassOffset; - - @HotSpotVMType(name = "BasicLock", get = HotSpotVMType.Type.SIZE) @Stable public int basicLockSize; - @HotSpotVMField(name = "BasicLock::_displaced_header", type = "markOop", get = HotSpotVMField.Type.OFFSET) @Stable public int basicLockDisplacedHeaderOffset; - - @HotSpotVMField(name = "Thread::_allocated_bytes", type = "jlong", get = HotSpotVMField.Type.OFFSET) @Stable public int threadAllocatedBytesOffset; - - @HotSpotVMFlag(name = "TLABWasteIncrement") @Stable public int tlabRefillWasteIncrement; - - @HotSpotVMField(name = "ThreadLocalAllocBuffer::_start", type = "HeapWord*", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferStartOffset; - @HotSpotVMField(name = "ThreadLocalAllocBuffer::_end", type = "HeapWord*", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferEndOffset; - @HotSpotVMField(name = "ThreadLocalAllocBuffer::_top", type = "HeapWord*", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferTopOffset; - @HotSpotVMField(name = "ThreadLocalAllocBuffer::_pf_top", type = "HeapWord*", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferPfTopOffset; - @HotSpotVMField(name = "ThreadLocalAllocBuffer::_slow_allocations", type = "unsigned", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferSlowAllocationsOffset; - @HotSpotVMField(name = "ThreadLocalAllocBuffer::_fast_refill_waste", type = "unsigned", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferFastRefillWasteOffset; - @HotSpotVMField(name = "ThreadLocalAllocBuffer::_number_of_refills", type = "unsigned", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferNumberOfRefillsOffset; - @HotSpotVMField(name = "ThreadLocalAllocBuffer::_refill_waste_limit", type = "size_t", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferRefillWasteLimitOffset; - @HotSpotVMField(name = "ThreadLocalAllocBuffer::_desired_size", type = "size_t", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferDesiredSizeOffset; - - public int tlabSlowAllocationsOffset() { - return threadTlabOffset + threadLocalAllocBufferSlowAllocationsOffset; - } - - public int tlabFastRefillWasteOffset() { - return threadTlabOffset + threadLocalAllocBufferFastRefillWasteOffset; - } - - public int tlabNumberOfRefillsOffset() { - return threadTlabOffset + threadLocalAllocBufferNumberOfRefillsOffset; - } - - public int tlabRefillWasteLimitOffset() { - return threadTlabOffset + threadLocalAllocBufferRefillWasteLimitOffset; - } - - public int threadTlabSizeOffset() { - return threadTlabOffset + threadLocalAllocBufferDesiredSizeOffset; - } - - public int threadTlabStartOffset() { - return threadTlabOffset + threadLocalAllocBufferStartOffset; - } - - public int threadTlabEndOffset() { - return threadTlabOffset + threadLocalAllocBufferEndOffset; - } - - public int threadTlabTopOffset() { - return threadTlabOffset + threadLocalAllocBufferTopOffset; - } - - public int threadTlabPfTopOffset() { - return threadTlabOffset + threadLocalAllocBufferPfTopOffset; - } - - @HotSpotVMField(name = "CompilerToVM::Data::ThreadLocalAllocBuffer_alignment_reserve", type = "size_t", get = HotSpotVMField.Type.VALUE) @Stable public int tlabAlignmentReserve; - - @HotSpotVMFlag(name = "TLABStats") @Stable public boolean tlabStats; - - // FIXME This is only temporary until the GC code is changed. - @HotSpotVMField(name = "CompilerToVM::Data::_supports_inline_contig_alloc", type = "bool", get = HotSpotVMField.Type.VALUE) @Stable public boolean inlineContiguousAllocationSupported; - @HotSpotVMField(name = "CompilerToVM::Data::_heap_end_addr", type = "HeapWord**", get = HotSpotVMField.Type.VALUE) @Stable public long heapEndAddress; - @HotSpotVMField(name = "CompilerToVM::Data::_heap_top_addr", type = "HeapWord**", get = HotSpotVMField.Type.VALUE) @Stable public long heapTopAddress; + final int klassOffset = getFieldValue("java_lang_Class::_klass_offset", Integer.class, "int"); /** * The DataLayout header size is the same as the cell size. */ - @HotSpotVMConstant(name = "DataLayout::cell_size") @Stable public int dataLayoutHeaderSize; - @HotSpotVMField(name = "DataLayout::_header._struct._tag", type = "u1", get = HotSpotVMField.Type.OFFSET) @Stable public int dataLayoutTagOffset; - @HotSpotVMField(name = "DataLayout::_header._struct._flags", type = "u1", get = HotSpotVMField.Type.OFFSET) @Stable public int dataLayoutFlagsOffset; - @HotSpotVMField(name = "DataLayout::_header._struct._bci", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int dataLayoutBCIOffset; - @HotSpotVMField(name = "DataLayout::_cells[0]", type = "intptr_t", get = HotSpotVMField.Type.OFFSET) @Stable public int dataLayoutCellsOffset; - @HotSpotVMConstant(name = "DataLayout::cell_size") @Stable public int dataLayoutCellSize; - - @HotSpotVMConstant(name = "DataLayout::no_tag") @Stable public int dataLayoutNoTag; - @HotSpotVMConstant(name = "DataLayout::bit_data_tag") @Stable public int dataLayoutBitDataTag; - @HotSpotVMConstant(name = "DataLayout::counter_data_tag") @Stable public int dataLayoutCounterDataTag; - @HotSpotVMConstant(name = "DataLayout::jump_data_tag") @Stable public int dataLayoutJumpDataTag; - @HotSpotVMConstant(name = "DataLayout::receiver_type_data_tag") @Stable public int dataLayoutReceiverTypeDataTag; - @HotSpotVMConstant(name = "DataLayout::virtual_call_data_tag") @Stable public int dataLayoutVirtualCallDataTag; - @HotSpotVMConstant(name = "DataLayout::ret_data_tag") @Stable public int dataLayoutRetDataTag; - @HotSpotVMConstant(name = "DataLayout::branch_data_tag") @Stable public int dataLayoutBranchDataTag; - @HotSpotVMConstant(name = "DataLayout::multi_branch_data_tag") @Stable public int dataLayoutMultiBranchDataTag; - @HotSpotVMConstant(name = "DataLayout::arg_info_data_tag") @Stable public int dataLayoutArgInfoDataTag; - @HotSpotVMConstant(name = "DataLayout::call_type_data_tag") @Stable public int dataLayoutCallTypeDataTag; - @HotSpotVMConstant(name = "DataLayout::virtual_call_type_data_tag") @Stable public int dataLayoutVirtualCallTypeDataTag; - @HotSpotVMConstant(name = "DataLayout::parameters_type_data_tag") @Stable public int dataLayoutParametersTypeDataTag; - @HotSpotVMConstant(name = "DataLayout::speculative_trap_data_tag") @Stable public int dataLayoutSpeculativeTrapDataTag; - - @HotSpotVMFlag(name = "BciProfileWidth") @Stable public int bciProfileWidth; - @HotSpotVMFlag(name = "TypeProfileWidth") @Stable public int typeProfileWidth; - @HotSpotVMFlag(name = "MethodProfileWidth") @Stable public int methodProfileWidth; - - @HotSpotVMField(name = "CompilerToVM::Data::SharedRuntime_ic_miss_stub", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long inlineCacheMissStub; - @HotSpotVMField(name = "CompilerToVM::Data::SharedRuntime_handle_wrong_method_stub", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long handleWrongMethodStub; - - @HotSpotVMField(name = "CompilerToVM::Data::SharedRuntime_deopt_blob_unpack", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long handleDeoptStub; - @HotSpotVMField(name = "CompilerToVM::Data::SharedRuntime_deopt_blob_uncommon_trap", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long uncommonTrapStub; - - @HotSpotVMField(name = "CodeCache::_low_bound", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long codeCacheLowBound; - @HotSpotVMField(name = "CodeCache::_high_bound", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long codeCacheHighBound; + final int dataLayoutHeaderSize = getConstant("DataLayout::cell_size", Integer.class); + final int dataLayoutTagOffset = getFieldOffset("DataLayout::_header._struct._tag", Integer.class, "u1"); + final int dataLayoutFlagsOffset = getFieldOffset("DataLayout::_header._struct._flags", Integer.class, "u1"); + final int dataLayoutBCIOffset = getFieldOffset("DataLayout::_header._struct._bci", Integer.class, "u2"); + final int dataLayoutCellSize = getConstant("DataLayout::cell_size", Integer.class); - @HotSpotVMField(name = "StubRoutines::_aescrypt_encryptBlock", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long aescryptEncryptBlockStub; - @HotSpotVMField(name = "StubRoutines::_aescrypt_decryptBlock", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long aescryptDecryptBlockStub; - @HotSpotVMField(name = "StubRoutines::_cipherBlockChaining_encryptAESCrypt", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long cipherBlockChainingEncryptAESCryptStub; - @HotSpotVMField(name = "StubRoutines::_cipherBlockChaining_decryptAESCrypt", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long cipherBlockChainingDecryptAESCryptStub; - @HotSpotVMField(name = "StubRoutines::_updateBytesCRC32", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long updateBytesCRC32Stub; - @HotSpotVMField(name = "StubRoutines::_crc_table_adr", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long crcTableAddress; - - @HotSpotVMField(name = "StubRoutines::_throw_delayed_StackOverflowError_entry", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long throwDelayedStackOverflowErrorEntry; + final int dataLayoutNoTag = getConstant("DataLayout::no_tag", Integer.class); + final int dataLayoutBitDataTag = getConstant("DataLayout::bit_data_tag", Integer.class); + final int dataLayoutCounterDataTag = getConstant("DataLayout::counter_data_tag", Integer.class); + final int dataLayoutJumpDataTag = getConstant("DataLayout::jump_data_tag", Integer.class); + final int dataLayoutReceiverTypeDataTag = getConstant("DataLayout::receiver_type_data_tag", Integer.class); + final int dataLayoutVirtualCallDataTag = getConstant("DataLayout::virtual_call_data_tag", Integer.class); + final int dataLayoutRetDataTag = getConstant("DataLayout::ret_data_tag", Integer.class); + final int dataLayoutBranchDataTag = getConstant("DataLayout::branch_data_tag", Integer.class); + final int dataLayoutMultiBranchDataTag = getConstant("DataLayout::multi_branch_data_tag", Integer.class); + final int dataLayoutArgInfoDataTag = getConstant("DataLayout::arg_info_data_tag", Integer.class); + final int dataLayoutCallTypeDataTag = getConstant("DataLayout::call_type_data_tag", Integer.class); + final int dataLayoutVirtualCallTypeDataTag = getConstant("DataLayout::virtual_call_type_data_tag", Integer.class); + final int dataLayoutParametersTypeDataTag = getConstant("DataLayout::parameters_type_data_tag", Integer.class); + final int dataLayoutSpeculativeTrapDataTag = getConstant("DataLayout::speculative_trap_data_tag", Integer.class); - @HotSpotVMField(name = "StubRoutines::_jbyte_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jbyteArraycopy; - @HotSpotVMField(name = "StubRoutines::_jshort_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jshortArraycopy; - @HotSpotVMField(name = "StubRoutines::_jint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jintArraycopy; - @HotSpotVMField(name = "StubRoutines::_jlong_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jlongArraycopy; - @HotSpotVMField(name = "StubRoutines::_oop_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long oopArraycopy; - @HotSpotVMField(name = "StubRoutines::_oop_arraycopy_uninit", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long oopArraycopyUninit; - @HotSpotVMField(name = "StubRoutines::_jbyte_disjoint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jbyteDisjointArraycopy; - @HotSpotVMField(name = "StubRoutines::_jshort_disjoint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jshortDisjointArraycopy; - @HotSpotVMField(name = "StubRoutines::_jint_disjoint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jintDisjointArraycopy; - @HotSpotVMField(name = "StubRoutines::_jlong_disjoint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jlongDisjointArraycopy; - @HotSpotVMField(name = "StubRoutines::_oop_disjoint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long oopDisjointArraycopy; - @HotSpotVMField(name = "StubRoutines::_oop_disjoint_arraycopy_uninit", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long oopDisjointArraycopyUninit; - @HotSpotVMField(name = "StubRoutines::_arrayof_jbyte_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jbyteAlignedArraycopy; - @HotSpotVMField(name = "StubRoutines::_arrayof_jshort_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jshortAlignedArraycopy; - @HotSpotVMField(name = "StubRoutines::_arrayof_jint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jintAlignedArraycopy; - @HotSpotVMField(name = "StubRoutines::_arrayof_jlong_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jlongAlignedArraycopy; - @HotSpotVMField(name = "StubRoutines::_arrayof_oop_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long oopAlignedArraycopy; - @HotSpotVMField(name = "StubRoutines::_arrayof_oop_arraycopy_uninit", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long oopAlignedArraycopyUninit; - @HotSpotVMField(name = "StubRoutines::_arrayof_jbyte_disjoint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jbyteAlignedDisjointArraycopy; - @HotSpotVMField(name = "StubRoutines::_arrayof_jshort_disjoint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jshortAlignedDisjointArraycopy; - @HotSpotVMField(name = "StubRoutines::_arrayof_jint_disjoint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jintAlignedDisjointArraycopy; - @HotSpotVMField(name = "StubRoutines::_arrayof_jlong_disjoint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jlongAlignedDisjointArraycopy; - @HotSpotVMField(name = "StubRoutines::_arrayof_oop_disjoint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long oopAlignedDisjointArraycopy; - @HotSpotVMField(name = "StubRoutines::_arrayof_oop_disjoint_arraycopy_uninit", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long oopAlignedDisjointArraycopyUninit; - @HotSpotVMField(name = "StubRoutines::_checkcast_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long checkcastArraycopy; - @HotSpotVMField(name = "StubRoutines::_checkcast_arraycopy_uninit", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long checkcastArraycopyUninit; - @HotSpotVMField(name = "StubRoutines::_unsafe_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long unsafeArraycopy; - @HotSpotVMField(name = "StubRoutines::_generic_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long genericArraycopy; - - @HotSpotVMAddress(name = "JVMCIRuntime::new_instance") @Stable public long newInstanceAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::new_array") @Stable public long newArrayAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::new_multi_array") @Stable public long newMultiArrayAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::dynamic_new_array") @Stable public long dynamicNewArrayAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::dynamic_new_instance") @Stable public long dynamicNewInstanceAddress; + final int bciProfileWidth = getFlag("BciProfileWidth", Integer.class); + final int typeProfileWidth = getFlag("TypeProfileWidth", Integer.class); + final int methodProfileWidth = getFlag("MethodProfileWidth", Integer.class); - @HotSpotVMAddress(name = "JVMCIRuntime::thread_is_interrupted") @Stable public long threadIsInterruptedAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::vm_message") @Stable public long vmMessageAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::identity_hash_code") @Stable public long identityHashCodeAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::exception_handler_for_pc") @Stable public long exceptionHandlerForPcAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::monitorenter") @Stable public long monitorenterAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::monitorexit") @Stable public long monitorexitAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::throw_and_post_jvmti_exception") @Stable public long throwAndPostJvmtiExceptionAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::throw_klass_external_name_exception") @Stable public long throwKlassExternalNameExceptionAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::throw_class_cast_exception") @Stable public long throwClassCastExceptionAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::log_primitive") @Stable public long logPrimitiveAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::log_object") @Stable public long logObjectAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::log_printf") @Stable public long logPrintfAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::vm_error") @Stable public long vmErrorAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::load_and_clear_exception") @Stable public long loadAndClearExceptionAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::write_barrier_pre") @Stable public long writeBarrierPreAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::write_barrier_post") @Stable public long writeBarrierPostAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::validate_object") @Stable public long validateObject; - - @HotSpotVMAddress(name = "JVMCIRuntime::test_deoptimize_call_int") @Stable public long testDeoptimizeCallInt; - - @HotSpotVMAddress(name = "SharedRuntime::register_finalizer") @Stable public long registerFinalizerAddress; - @HotSpotVMAddress(name = "SharedRuntime::exception_handler_for_return_address") @Stable public long exceptionHandlerForReturnAddressAddress; - @HotSpotVMAddress(name = "SharedRuntime::OSR_migration_end") @Stable public long osrMigrationEndAddress; - @HotSpotVMAddress(name = "SharedRuntime::enable_stack_reserved_zone") @Stable public long enableStackReservedZoneAddress; - - @HotSpotVMAddress(name = "os::javaTimeMillis") @Stable public long javaTimeMillisAddress; - @HotSpotVMAddress(name = "os::javaTimeNanos") @Stable public long javaTimeNanosAddress; - @HotSpotVMField(name = "CompilerToVM::Data::dsin", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long arithmeticSinAddress; - @HotSpotVMField(name = "CompilerToVM::Data::dcos", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long arithmeticCosAddress; - @HotSpotVMField(name = "CompilerToVM::Data::dtan", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long arithmeticTanAddress; - @HotSpotVMField(name = "CompilerToVM::Data::dexp", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long arithmeticExpAddress; - @HotSpotVMField(name = "CompilerToVM::Data::dlog", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long arithmeticLogAddress; - @HotSpotVMField(name = "CompilerToVM::Data::dlog10", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long arithmeticLog10Address; - @HotSpotVMField(name = "CompilerToVM::Data::dpow", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long arithmeticPowAddress; - - @HotSpotVMFlag(name = "JVMCICounterSize") @Stable public int jvmciCountersSize; - - @HotSpotVMAddress(name = "Deoptimization::fetch_unroll_info") @Stable public long deoptimizationFetchUnrollInfo; - @HotSpotVMAddress(name = "Deoptimization::uncommon_trap") @Stable public long deoptimizationUncommonTrap; - @HotSpotVMAddress(name = "Deoptimization::unpack_frames") @Stable public long deoptimizationUnpackFrames; + final int deoptReasonNone = getConstant("Deoptimization::Reason_none", Integer.class); + final int deoptReasonNullCheck = getConstant("Deoptimization::Reason_null_check", Integer.class); + final int deoptReasonRangeCheck = getConstant("Deoptimization::Reason_range_check", Integer.class); + final int deoptReasonClassCheck = getConstant("Deoptimization::Reason_class_check", Integer.class); + final int deoptReasonArrayCheck = getConstant("Deoptimization::Reason_array_check", Integer.class); + final int deoptReasonUnreached0 = getConstant("Deoptimization::Reason_unreached0", Integer.class); + final int deoptReasonTypeCheckInlining = getConstant("Deoptimization::Reason_type_checked_inlining", Integer.class); + final int deoptReasonOptimizedTypeCheck = getConstant("Deoptimization::Reason_optimized_type_check", Integer.class); + final int deoptReasonNotCompiledExceptionHandler = getConstant("Deoptimization::Reason_not_compiled_exception_handler", Integer.class); + final int deoptReasonUnresolved = getConstant("Deoptimization::Reason_unresolved", Integer.class); + final int deoptReasonJsrMismatch = getConstant("Deoptimization::Reason_jsr_mismatch", Integer.class); + final int deoptReasonDiv0Check = getConstant("Deoptimization::Reason_div0_check", Integer.class); + final int deoptReasonConstraint = getConstant("Deoptimization::Reason_constraint", Integer.class); + final int deoptReasonLoopLimitCheck = getConstant("Deoptimization::Reason_loop_limit_check", Integer.class); + final int deoptReasonAliasing = getConstant("Deoptimization::Reason_aliasing", Integer.class); + final int deoptReasonTransferToInterpreter = getConstant("Deoptimization::Reason_transfer_to_interpreter", Integer.class); + final int deoptReasonOSROffset = getConstant("Deoptimization::Reason_LIMIT", Integer.class); - @HotSpotVMConstant(name = "Deoptimization::Reason_none") @Stable public int deoptReasonNone; - @HotSpotVMConstant(name = "Deoptimization::Reason_null_check") @Stable public int deoptReasonNullCheck; - @HotSpotVMConstant(name = "Deoptimization::Reason_range_check") @Stable public int deoptReasonRangeCheck; - @HotSpotVMConstant(name = "Deoptimization::Reason_class_check") @Stable public int deoptReasonClassCheck; - @HotSpotVMConstant(name = "Deoptimization::Reason_array_check") @Stable public int deoptReasonArrayCheck; - @HotSpotVMConstant(name = "Deoptimization::Reason_unreached0") @Stable public int deoptReasonUnreached0; - @HotSpotVMConstant(name = "Deoptimization::Reason_type_checked_inlining") @Stable public int deoptReasonTypeCheckInlining; - @HotSpotVMConstant(name = "Deoptimization::Reason_optimized_type_check") @Stable public int deoptReasonOptimizedTypeCheck; - @HotSpotVMConstant(name = "Deoptimization::Reason_not_compiled_exception_handler") @Stable public int deoptReasonNotCompiledExceptionHandler; - @HotSpotVMConstant(name = "Deoptimization::Reason_unresolved") @Stable public int deoptReasonUnresolved; - @HotSpotVMConstant(name = "Deoptimization::Reason_jsr_mismatch") @Stable public int deoptReasonJsrMismatch; - @HotSpotVMConstant(name = "Deoptimization::Reason_div0_check") @Stable public int deoptReasonDiv0Check; - @HotSpotVMConstant(name = "Deoptimization::Reason_constraint") @Stable public int deoptReasonConstraint; - @HotSpotVMConstant(name = "Deoptimization::Reason_loop_limit_check") @Stable public int deoptReasonLoopLimitCheck; - @HotSpotVMConstant(name = "Deoptimization::Reason_aliasing") @Stable public int deoptReasonAliasing; - @HotSpotVMConstant(name = "Deoptimization::Reason_transfer_to_interpreter") @Stable public int deoptReasonTransferToInterpreter; - @HotSpotVMConstant(name = "Deoptimization::Reason_LIMIT") @Stable public int deoptReasonOSROffset; + final int deoptActionNone = getConstant("Deoptimization::Action_none", Integer.class); + final int deoptActionMaybeRecompile = getConstant("Deoptimization::Action_maybe_recompile", Integer.class); + final int deoptActionReinterpret = getConstant("Deoptimization::Action_reinterpret", Integer.class); + final int deoptActionMakeNotEntrant = getConstant("Deoptimization::Action_make_not_entrant", Integer.class); + final int deoptActionMakeNotCompilable = getConstant("Deoptimization::Action_make_not_compilable", Integer.class); - @HotSpotVMConstant(name = "Deoptimization::Action_none") @Stable public int deoptActionNone; - @HotSpotVMConstant(name = "Deoptimization::Action_maybe_recompile") @Stable public int deoptActionMaybeRecompile; - @HotSpotVMConstant(name = "Deoptimization::Action_reinterpret") @Stable public int deoptActionReinterpret; - @HotSpotVMConstant(name = "Deoptimization::Action_make_not_entrant") @Stable public int deoptActionMakeNotEntrant; - @HotSpotVMConstant(name = "Deoptimization::Action_make_not_compilable") @Stable public int deoptActionMakeNotCompilable; + final int deoptimizationActionBits = getConstant("Deoptimization::_action_bits", Integer.class); + final int deoptimizationReasonBits = getConstant("Deoptimization::_reason_bits", Integer.class); + final int deoptimizationDebugIdBits = getConstant("Deoptimization::_debug_id_bits", Integer.class); + final int deoptimizationActionShift = getConstant("Deoptimization::_action_shift", Integer.class); + final int deoptimizationReasonShift = getConstant("Deoptimization::_reason_shift", Integer.class); + final int deoptimizationDebugIdShift = getConstant("Deoptimization::_debug_id_shift", Integer.class); - @HotSpotVMConstant(name = "Deoptimization::_action_bits") @Stable public int deoptimizationActionBits; - @HotSpotVMConstant(name = "Deoptimization::_reason_bits") @Stable public int deoptimizationReasonBits; - @HotSpotVMConstant(name = "Deoptimization::_debug_id_bits") @Stable public int deoptimizationDebugIdBits; - @HotSpotVMConstant(name = "Deoptimization::_action_shift") @Stable public int deoptimizationActionShift; - @HotSpotVMConstant(name = "Deoptimization::_reason_shift") @Stable public int deoptimizationReasonShift; - @HotSpotVMConstant(name = "Deoptimization::_debug_id_shift") @Stable public int deoptimizationDebugIdShift; - - @HotSpotVMConstant(name = "Deoptimization::Unpack_deopt") @Stable public int deoptimizationUnpackDeopt; - @HotSpotVMConstant(name = "Deoptimization::Unpack_exception") @Stable public int deoptimizationUnpackException; - @HotSpotVMConstant(name = "Deoptimization::Unpack_uncommon_trap") @Stable public int deoptimizationUnpackUncommonTrap; - @HotSpotVMConstant(name = "Deoptimization::Unpack_reexecute") @Stable public int deoptimizationUnpackReexecute; + final int vmIntrinsicInvokeBasic = getConstant("vmIntrinsics::_invokeBasic", Integer.class); + final int vmIntrinsicLinkToVirtual = getConstant("vmIntrinsics::_linkToVirtual", Integer.class); + final int vmIntrinsicLinkToStatic = getConstant("vmIntrinsics::_linkToStatic", Integer.class); + final int vmIntrinsicLinkToSpecial = getConstant("vmIntrinsics::_linkToSpecial", Integer.class); + final int vmIntrinsicLinkToInterface = getConstant("vmIntrinsics::_linkToInterface", Integer.class); - @HotSpotVMField(name = "Deoptimization::UnrollBlock::_size_of_deoptimized_frame", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int deoptimizationUnrollBlockSizeOfDeoptimizedFrameOffset; - @HotSpotVMField(name = "Deoptimization::UnrollBlock::_caller_adjustment", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int deoptimizationUnrollBlockCallerAdjustmentOffset; - @HotSpotVMField(name = "Deoptimization::UnrollBlock::_number_of_frames", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int deoptimizationUnrollBlockNumberOfFramesOffset; - @HotSpotVMField(name = "Deoptimization::UnrollBlock::_total_frame_sizes", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int deoptimizationUnrollBlockTotalFrameSizesOffset; - @HotSpotVMField(name = "Deoptimization::UnrollBlock::_unpack_kind", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int deoptimizationUnrollBlockUnpackKindOffset; - @HotSpotVMField(name = "Deoptimization::UnrollBlock::_frame_sizes", type = "intptr_t*", get = HotSpotVMField.Type.OFFSET) @Stable public int deoptimizationUnrollBlockFrameSizesOffset; - @HotSpotVMField(name = "Deoptimization::UnrollBlock::_frame_pcs", type = "address*", get = HotSpotVMField.Type.OFFSET) @Stable public int deoptimizationUnrollBlockFramePcsOffset; - @HotSpotVMField(name = "Deoptimization::UnrollBlock::_initial_info", type = "intptr_t", get = HotSpotVMField.Type.OFFSET) @Stable public int deoptimizationUnrollBlockInitialInfoOffset; + final int codeInstallResultOk = getConstant("JVMCIEnv::ok", Integer.class); + final int codeInstallResultDependenciesFailed = getConstant("JVMCIEnv::dependencies_failed", Integer.class); + final int codeInstallResultDependenciesInvalid = getConstant("JVMCIEnv::dependencies_invalid", Integer.class); + final int codeInstallResultCacheFull = getConstant("JVMCIEnv::cache_full", Integer.class); + final int codeInstallResultCodeTooLarge = getConstant("JVMCIEnv::code_too_large", Integer.class); - @HotSpotVMConstant(name = "vmIntrinsics::_invokeBasic") @Stable public int vmIntrinsicInvokeBasic; - @HotSpotVMConstant(name = "vmIntrinsics::_linkToVirtual") @Stable public int vmIntrinsicLinkToVirtual; - @HotSpotVMConstant(name = "vmIntrinsics::_linkToStatic") @Stable public int vmIntrinsicLinkToStatic; - @HotSpotVMConstant(name = "vmIntrinsics::_linkToSpecial") @Stable public int vmIntrinsicLinkToSpecial; - @HotSpotVMConstant(name = "vmIntrinsics::_linkToInterface") @Stable public int vmIntrinsicLinkToInterface; - - @HotSpotVMConstant(name = "JVMCIEnv::ok") @Stable public int codeInstallResultOk; - @HotSpotVMConstant(name = "JVMCIEnv::dependencies_failed") @Stable public int codeInstallResultDependenciesFailed; - @HotSpotVMConstant(name = "JVMCIEnv::dependencies_invalid") @Stable public int codeInstallResultDependenciesInvalid; - @HotSpotVMConstant(name = "JVMCIEnv::cache_full") @Stable public int codeInstallResultCacheFull; - @HotSpotVMConstant(name = "JVMCIEnv::code_too_large") @Stable public int codeInstallResultCodeTooLarge; - - public String getCodeInstallResultDescription(int codeInstallResult) { + String getCodeInstallResultDescription(int codeInstallResult) { if (codeInstallResult == codeInstallResultOk) { return "ok"; } @@ -1677,114 +330,17 @@ return "unknown"; } - // Checkstyle: stop - @HotSpotVMConstant(name = "CodeInstaller::VERIFIED_ENTRY") @Stable public int MARKID_VERIFIED_ENTRY; - @HotSpotVMConstant(name = "CodeInstaller::UNVERIFIED_ENTRY") @Stable public int MARKID_UNVERIFIED_ENTRY; - @HotSpotVMConstant(name = "CodeInstaller::OSR_ENTRY") @Stable public int MARKID_OSR_ENTRY; - @HotSpotVMConstant(name = "CodeInstaller::EXCEPTION_HANDLER_ENTRY") @Stable public int MARKID_EXCEPTION_HANDLER_ENTRY; - @HotSpotVMConstant(name = "CodeInstaller::DEOPT_HANDLER_ENTRY") @Stable public int MARKID_DEOPT_HANDLER_ENTRY; - @HotSpotVMConstant(name = "CodeInstaller::INVOKEINTERFACE") @Stable public int MARKID_INVOKEINTERFACE; - @HotSpotVMConstant(name = "CodeInstaller::INVOKEVIRTUAL") @Stable public int MARKID_INVOKEVIRTUAL; - @HotSpotVMConstant(name = "CodeInstaller::INVOKESTATIC") @Stable public int MARKID_INVOKESTATIC; - @HotSpotVMConstant(name = "CodeInstaller::INVOKESPECIAL") @Stable public int MARKID_INVOKESPECIAL; - @HotSpotVMConstant(name = "CodeInstaller::INLINE_INVOKE") @Stable public int MARKID_INLINE_INVOKE; - @HotSpotVMConstant(name = "CodeInstaller::POLL_NEAR") @Stable public int MARKID_POLL_NEAR; - @HotSpotVMConstant(name = "CodeInstaller::POLL_RETURN_NEAR") @Stable public int MARKID_POLL_RETURN_NEAR; - @HotSpotVMConstant(name = "CodeInstaller::POLL_FAR") @Stable public int MARKID_POLL_FAR; - @HotSpotVMConstant(name = "CodeInstaller::POLL_RETURN_FAR") @Stable public int MARKID_POLL_RETURN_FAR; - @HotSpotVMConstant(name = "CodeInstaller::CARD_TABLE_SHIFT") @Stable public int MARKID_CARD_TABLE_SHIFT; - @HotSpotVMConstant(name = "CodeInstaller::CARD_TABLE_ADDRESS") @Stable public int MARKID_CARD_TABLE_ADDRESS; - @HotSpotVMConstant(name = "CodeInstaller::HEAP_TOP_ADDRESS") @Stable public int MARKID_HEAP_TOP_ADDRESS; - @HotSpotVMConstant(name = "CodeInstaller::HEAP_END_ADDRESS") @Stable public int MARKID_HEAP_END_ADDRESS; - @HotSpotVMConstant(name = "CodeInstaller::NARROW_KLASS_BASE_ADDRESS") @Stable public int MARKID_NARROW_KLASS_BASE_ADDRESS; - @HotSpotVMConstant(name = "CodeInstaller::CRC_TABLE_ADDRESS") @Stable public int MARKID_CRC_TABLE_ADDRESS; - @HotSpotVMConstant(name = "CodeInstaller::INVOKE_INVALID") @Stable public int MARKID_INVOKE_INVALID; - - @HotSpotVMConstant(name = "BitData::exception_seen_flag") @Stable public int bitDataExceptionSeenFlag; - @HotSpotVMConstant(name = "BitData::null_seen_flag") @Stable public int bitDataNullSeenFlag; - @HotSpotVMConstant(name = "CounterData::count_off") @Stable public int methodDataCountOffset; - @HotSpotVMConstant(name = "JumpData::taken_off_set") @Stable public int jumpDataTakenOffset; - @HotSpotVMConstant(name = "JumpData::displacement_off_set") @Stable public int jumpDataDisplacementOffset; - @HotSpotVMConstant(name = "ReceiverTypeData::nonprofiled_count_off_set") @Stable public int receiverTypeDataNonprofiledCountOffset; - @HotSpotVMConstant(name = "ReceiverTypeData::receiver_type_row_cell_count") @Stable public int receiverTypeDataReceiverTypeRowCellCount; - @HotSpotVMConstant(name = "ReceiverTypeData::receiver0_offset") @Stable public int receiverTypeDataReceiver0Offset; - @HotSpotVMConstant(name = "ReceiverTypeData::count0_offset") @Stable public int receiverTypeDataCount0Offset; - @HotSpotVMConstant(name = "BranchData::not_taken_off_set") @Stable public int branchDataNotTakenOffset; - @HotSpotVMConstant(name = "ArrayData::array_len_off_set") @Stable public int arrayDataArrayLenOffset; - @HotSpotVMConstant(name = "ArrayData::array_start_off_set") @Stable public int arrayDataArrayStartOffset; - @HotSpotVMConstant(name = "MultiBranchData::per_case_cell_count") @Stable public int multiBranchDataPerCaseCellCount; - - // Checkstyle: resume - - private boolean check() { - for (Field f : getClass().getDeclaredFields()) { - int modifiers = f.getModifiers(); - if (Modifier.isPublic(modifiers) && !Modifier.isStatic(modifiers)) { - assert Modifier.isFinal(modifiers) || f.getAnnotation(Stable.class) != null : "field should either be final or @Stable: " + f; - } - } - - assert codeEntryAlignment > 0 : codeEntryAlignment; - 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; - } - - /** - * A compact representation of the different encoding strategies for Objects and metadata. - */ - public static class CompressEncoding { - public final long base; - public final int shift; - public final int alignment; - - CompressEncoding(long base, int shift, int alignment) { - this.base = base; - this.shift = shift; - this.alignment = alignment; - } - - public int compress(long ptr) { - if (ptr == 0L) { - return 0; - } else { - return (int) ((ptr - base) >>> shift); - } - } - - public long uncompress(int ptr) { - if (ptr == 0) { - return 0L; - } else { - return ((ptr & 0xFFFFFFFFL) << shift) + base; - } - } - - @Override - public String toString() { - return "base: " + base + " shift: " + shift + " alignment: " + alignment; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + alignment; - result = prime * result + (int) (base ^ (base >>> 32)); - result = prime * result + shift; - return result; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof CompressEncoding) { - CompressEncoding other = (CompressEncoding) obj; - return alignment == other.alignment && base == other.base && shift == other.shift; - } else { - return false; - } - } - } - + final int bitDataExceptionSeenFlag = getConstant("BitData::exception_seen_flag", Integer.class); + final int bitDataNullSeenFlag = getConstant("BitData::null_seen_flag", Integer.class); + final int methodDataCountOffset = getConstant("CounterData::count_off", Integer.class); + final int jumpDataTakenOffset = getConstant("JumpData::taken_off_set", Integer.class); + final int jumpDataDisplacementOffset = getConstant("JumpData::displacement_off_set", Integer.class); + final int receiverTypeDataNonprofiledCountOffset = getConstant("ReceiverTypeData::nonprofiled_count_off_set", Integer.class); + final int receiverTypeDataReceiverTypeRowCellCount = getConstant("ReceiverTypeData::receiver_type_row_cell_count", Integer.class); + final int receiverTypeDataReceiver0Offset = getConstant("ReceiverTypeData::receiver0_offset", Integer.class); + final int receiverTypeDataCount0Offset = getConstant("ReceiverTypeData::count0_offset", Integer.class); + final int branchDataNotTakenOffset = getConstant("BranchData::not_taken_off_set", Integer.class); + 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); } diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfigAccess.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfigAccess.java Thu Jun 16 16:41:50 2016 +0000 @@ -0,0 +1,327 @@ +/* + * Copyright (c) 2016, 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 jdk.vm.ci.common.JVMCIError; + +/** + * Access to VM configuration data. + */ +public class HotSpotVMConfigAccess { + + /** + * Gets the address of a C++ symbol. + * + * @param name name of C++ symbol + * @param notPresent if non-null and the symbol is not present then this value is returned + * @return the address of the symbol + * @throws JVMCIError if the symbol is not present and {@code notPresent == null} + */ + public long getAddress(String name, Long notPresent) { + Long entry = store.vmAddresses.get(name); + if (entry == null) { + if (notPresent != null) { + return notPresent; + } + throw new JVMCIError("expected VM symbol not found: " + name); + } + return entry; + } + + /** + * Gets the address of a C++ symbol. + * + * @param name name of C++ symbol + * @return the address of the symbol + * @throws JVMCIError if the symbol is not present + */ + public long getAddress(String name) { + return getAddress(name, null); + } + + /** + * Gets the size of a C++ type. + * + * @param name name of the type + * @return the size in bytes of the requested field + * @throws JVMCIError if the field is not present and {@code notPresent} is null + */ + public int getTypeSize(String name) { + Long entry = store.vmTypeSizes.get(name); + if (entry == null) { + throw new JVMCIError("expected VM type not found: " + name); + } + return (int) (long) entry; + } + + /** + * Gets the value of a C++ constant. + * + * @param name name of the constant (e.g., {@code "frame::arg_reg_save_area_bytes"}) + * @param type the boxed type to which the constant value will be converted + * @param notPresent if non-null and the constant is not present then this value is returned + * @return the constant value converted to {@code type} + * @throws JVMCIError if the constant is not present and {@code notPresent == null} + */ + public T getConstant(String name, Class type, T notPresent) { + Long c = store.vmConstants.get(name); + if (c == null) { + if (notPresent != null) { + return notPresent; + } + throw new JVMCIError("expected VM constant not found: " + name); + } + return type.cast(convertValue(name, type, c, null)); + } + + /** + * Gets the value of a C++ constant. + * + * @param name name of the constant (e.g., {@code "frame::arg_reg_save_area_bytes"}) + * @param type the boxed type to which the constant value will be converted + * @return the constant value converted to {@code type} + * @throws JVMCIError if the constant is not present + */ + public T getConstant(String name, Class type) { + return getConstant(name, type, null); + } + + /** + * Gets the offset of a non-static C++ field. + * + * @param name fully qualified name of the field + * @param type the boxed type to which the offset value will be converted (must be + * {@link Integer} or {@link Long}) + * @param cppType if non-null, the expected C++ type of the field (e.g., {@code "HeapWord*"}) + * @param notPresent if non-null and the field is not present then this value is returned + * @return the offset in bytes of the requested field + * @throws JVMCIError if the field is static or not present and {@code notPresent} is null + */ + public T getFieldOffset(String name, Class type, String cppType, T notPresent) { + assert type == Integer.class || type == Long.class; + VMField entry = getField(name, cppType, notPresent == null); + if (entry == null) { + return notPresent; + } + if (entry.address != 0) { + throw new JVMCIError("cannot get offset of static field " + name); + } + return entry == null ? notPresent : type.cast(convertValue(name, type, entry.offset, cppType)); + } + + /** + * Gets the offset of a non-static C++ field. + * + * @param name fully qualified name of the field + * @param type the boxed type to which the offset value will be converted (must be + * {@link Integer} or {@link Long}) + * @param cppType if non-null, the expected C++ type of the field (e.g., {@code "HeapWord*"}) + * @return the offset in bytes of the requested field + * @throws JVMCIError if the field is static or not present + */ + public T getFieldOffset(String name, Class type, String cppType) { + return getFieldOffset(name, type, cppType, null); + } + + /** + * Gets the offset of a non-static C++ field. + * + * @param name fully qualified name of the field + * @param type the boxed type to which the offset value will be converted (must be + * {@link Integer} or {@link Long}) + * @return the offset in bytes of the requested field + * @throws JVMCIError if the field is static or not present + */ + public T getFieldOffset(String name, Class type) { + return getFieldOffset(name, type, null, null); + } + + /** + * Gets the address of a static C++ field. + * + * @param name fully qualified name of the field + * @param cppType if non-null, the expected C++ type of the field (e.g., {@code "HeapWord*"}) + * @param notPresent if non-null and the field is not present then this value is returned + * @return the address of the requested field + * @throws JVMCIError if the field is not static or not present and {@code notPresent} is null + */ + public long getFieldAddress(String name, String cppType, Long notPresent) { + VMField entry = getField(name, cppType, notPresent == null); + if (entry == null) { + return notPresent; + } + if (entry.address == 0) { + throw new JVMCIError(name + " is not a static field"); + } + return entry == null ? notPresent : entry.address; + } + + /** + * Gets the address of a static C++ field. + * + * @param name fully qualified name of the field + * @param cppType if non-null, the expected C++ type of the field (e.g., {@code "HeapWord*"}) + * @return the address of the requested field + * @throws JVMCIError if the field is not static or not present + */ + public long getFieldAddress(String name, String cppType) { + return getFieldAddress(name, cppType, null); + } + + /** + * Gets the value of a static C++ field. + * + * @param name fully qualified name of the field + * @param type the boxed type to which the constant value will be converted + * @param cppType if non-null, the expected C++ type of the field (e.g., {@code "HeapWord*"}) + * @param notPresent if non-null and the field is not present then this value is returned + * @return the value of the requested field + * @throws JVMCIError if the field is not static or not present and {@code notPresent} is null + */ + public T getFieldValue(String name, Class type, String cppType, T notPresent) { + VMField entry = getField(name, cppType, notPresent == null); + if (entry == null) { + return notPresent; + } + if (entry.value == null) { + throw new JVMCIError(name + " is not a static field"); + } + return type.cast(convertValue(name, type, entry.value, cppType)); + } + + /** + * Gets the value of a static C++ field. + * + * @param name fully qualified name of the field + * @param type the boxed type to which the constant value will be converted + * @param cppType if non-null, the expected C++ type of the field (e.g., {@code "HeapWord*"}) + * @return the value of the requested field + * @throws JVMCIError if the field is not static or not present + */ + public T getFieldValue(String name, Class type, String cppType) { + return getFieldValue(name, type, cppType, null); + } + + /** + * Gets the value of a static C++ field. + * + * @param name fully qualified name of the field + * @param type the boxed type to which the constant value will be converted + * @return the value of the requested field + * @throws JVMCIError if the field is not static or not present + */ + public T getFieldValue(String name, Class type) { + return getFieldValue(name, type, null, null); + } + + /** + * Gets a C++ field. + * + * @param name fully qualified name of the field + * @param cppType if non-null, the expected C++ type of the field (e.g., {@code "HeapWord*"}) + * @param required specifies if the field must be present + * @return the field + * @throws JVMCIError if the field is not present and {@code required == true} + */ + private VMField getField(String name, String cppType, boolean required) { + VMField entry = store.vmFields.get(name); + if (entry == null) { + if (!required) { + return null; + } + throw new JVMCIError("expected VM field not found: " + name); + } + + // Make sure the native type is still the type we expect. + if (cppType != null && !cppType.equals(entry.type)) { + throw new JVMCIError("expected type " + cppType + " but VM field " + name + " is of type " + entry.type); + } + return entry; + } + + /** + * Gets a VM flag value. + * + * @param name name of the flag (e.g., {@code "CompileTheWorldStartAt"}) + * @param type the boxed type to which the flag's value will be converted + * @return the flag's value converted to {@code type} or {@code notPresent} if the flag is not + * present + * @throws JVMCIError if the flag is not present + */ + public T getFlag(String name, Class type) { + return getFlag(name, type, null); + } + + /** + * Gets a VM flag value. + * + * @param name name of the flag (e.g., {@code "CompileTheWorldStartAt"}) + * @param type the boxed type to which the flag's value will be converted + * @param notPresent if non-null and the flag is not present then this value is returned + * @return the flag's value converted to {@code type} or {@code notPresent} if the flag is not + * present + * @throws JVMCIError if the flag is not present and {@code notPresent == null} + */ + public T getFlag(String name, Class type, T notPresent) { + VMFlag entry = store.vmFlags.get(name); + if (entry == null) { + if (notPresent != null) { + return notPresent; + } + throw new JVMCIError("expected VM flag not found: " + name); + } + return type.cast(convertValue(name, type, entry.value, entry.type)); + } + + private static Object convertValue(String name, Class toType, Object value, String cppType) throws JVMCIError { + if (toType == Boolean.class) { + if (value instanceof String) { + return Boolean.valueOf((String) value); + } else if (value instanceof Boolean) { + return value; + } else if (value instanceof Long) { + return ((long) value) != 0; + } + } else if (toType == Byte.class) { + if (value instanceof Long) { + return (byte) (long) value; + } + } else if (toType == Integer.class) { + if (value instanceof Integer) { + return value; + } else if (value instanceof Long) { + return (int) (long) value; + } + } else if (toType == Long.class) { + return (long) value; + } + + throw new JVMCIError("cannot convert " + name + " of type " + value.getClass().getSimpleName() + (cppType == null ? "" : " [" + cppType + "]") + " to " + toType.getSimpleName()); + } + + private final HotSpotVMConfigStore store; + + public HotSpotVMConfigAccess(HotSpotVMConfigStore store) { + this.store = store; + } +} diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfigStore.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfigStore.java Thu Jun 16 16:41:50 2016 +0000 @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2016, 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 jdk.vm.ci.common.InitTimer.timer; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import jdk.vm.ci.common.InitTimer; + +/** + * Access to VM configuration data. + */ +public final class HotSpotVMConfigStore { + + /** + * Gets the C++ symbols whose addresses are exposed by this object. + * + * @return an unmodifiable map from the symbol names to their addresses + */ + public Map getAddresses() { + return Collections.unmodifiableMap(vmAddresses); + } + + /** + * Gets the C++ type sizes exposed by this object. + * + * @return an unmodifiable map from C++ type names to their sizes in bytes + */ + public Map getTypeSizes() { + return Collections.unmodifiableMap(vmTypeSizes); + } + + /** + * Gets the C++ constants exposed by this object. + * + * @return an unmodifiable map from the names of C++ constants to their values + */ + public Map getConstants() { + return Collections.unmodifiableMap(vmConstants); + } + + /** + * Gets the VM flags exposed by this object. + * + * @return an unmodifiable map from VM flag names to {@link VMFlag} objects + */ + public Map getFlags() { + return Collections.unmodifiableMap(vmFlags); + } + + /** + * Gets the C++ fields exposed by this object. + * + * @return an unmodifiable map from VM field names to {@link VMField} objects + */ + public Map getFields() { + return Collections.unmodifiableMap(vmFields); + } + + final HashMap vmFields; + final HashMap vmTypeSizes; + final HashMap vmConstants; + final HashMap vmAddresses; + final HashMap vmFlags; + + /** + * Reads the database of VM info. The return value encodes the info in a nested object array + * that is described by the pseudo Java object {@code info} below: + * + *
    +     *     info = [
    +     *         VMField[] vmFields,
    +     *         [String name, Long size, ...] vmTypeSizes,
    +     *         [String name, Long value, ...] vmConstants,
    +     *         [String name, Long value, ...] vmAddresses,
    +     *         VMFlag[] vmFlags
    +     *     ]
    +     * 
    + */ + @SuppressWarnings("try") + HotSpotVMConfigStore(CompilerToVM compilerToVm) { + Object[] data; + try (InitTimer t = timer("CompilerToVm readConfiguration")) { + data = compilerToVm.readConfiguration(); + } + assert data.length == 5 : data.length; + + // @formatter:off + VMField[] vmFieldsInfo = (VMField[]) data[0]; + Object[] vmTypesSizesInfo = (Object[]) data[1]; + Object[] vmConstantsInfo = (Object[]) data[2]; + Object[] vmAddressesInfo = (Object[]) data[3]; + VMFlag[] vmFlagsInfo = (VMFlag[]) data[4]; + + vmFields = new HashMap<>(vmFieldsInfo.length); + vmTypeSizes = new HashMap<>(vmTypesSizesInfo.length); + vmConstants = new HashMap<>(vmConstantsInfo.length); + vmAddresses = new HashMap<>(vmAddressesInfo.length); + vmFlags = new HashMap<>(vmFlagsInfo.length); + // @formatter:on + + try (InitTimer t = timer("HotSpotVMConfigStore fill maps")) { + for (VMField vmField : vmFieldsInfo) { + vmFields.put(vmField.name, vmField); + } + + for (int i = 0; i < vmTypesSizesInfo.length / 2; i++) { + String name = (String) vmTypesSizesInfo[i * 2]; + Long size = (Long) vmTypesSizesInfo[i * 2 + 1]; + vmTypeSizes.put(name, size); + } + + for (int i = 0; i < vmConstantsInfo.length / 2; i++) { + String name = (String) vmConstantsInfo[i * 2]; + Long value = (Long) vmConstantsInfo[i * 2 + 1]; + vmConstants.put(name, value); + } + + for (int i = 0; i < vmAddressesInfo.length / 2; i++) { + String name = (String) vmAddressesInfo[i * 2]; + Long value = (Long) vmAddressesInfo[i * 2 + 1]; + vmAddresses.put(name, value); + } + + for (VMFlag vmFlag : vmFlagsInfo) { + vmFlags.put(vmFlag.name, vmFlag); + } + } + } +} diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfigVerifier.java --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfigVerifier.java Wed Jun 01 09:13:10 2016 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,164 +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.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 jdk.internal.misc.Unsafe; - -/** - * 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 - * {@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 extends ClassVisitor { - - 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 HotSpotVMConfigVerifier(); - cr.accept(cv, 0); - return true; - } catch (IOException e) { - throw new JVMCIError(e); - } - } - - /** - * Source file context for error reporting. - */ - String sourceFile = null; - - /** - * Line number for error reporting. - */ - int lineNo = -1; - - private static Class resolve(String name) { - try { - return Class.forName(name.replace('/', '.')); - } catch (ClassNotFoundException e) { - throw new JVMCIError(e); - } - } - - HotSpotVMConfigVerifier() { - 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; - } - } -} diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/VMField.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/VMField.java Thu Jun 16 16:41:50 2016 +0000 @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2016, 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; + +/** + * Describes a C++ field exposed via {@link HotSpotVMConfigAccess}. + */ +public final class VMField { + + /** + * Fully qualified name of the represented field (e.g., "Klass::_name"). + */ + public final String name; + + /** + * The represented field's type (e.g., "Symbol*"). This may be {@code null}. + */ + public final String type; + + /** + * If represented field is non-static, this is its offset within the containing structure. + */ + public final long offset; + + /** + * If represented field is static, this is its address. Otherwise, this field is 0. + */ + public final long address; + + /** + * Value of the field represented as a boxed long; only valid for non-oop static fields. This + * value is only captured once, during JVMCI initialization. If {@link #type} cannot be + * meaningfully (e.g., a struct) or safely (e.g., an oop) expressed as a boxed long, this is + * {@code null}. + */ + public final Long value; + + /** + * Determines if the represented field is static. + */ + public boolean isStatic() { + return address != 0; + } + + /** + * Creates a description of a non-static field. + */ + public VMField(String name, String type, long offset) { + this.name = name; + this.type = type; + this.offset = offset; + this.address = 0; + this.value = null; + } + + /** + * Creates a description of a static field. + */ + public VMField(String name, String type, long address, Long value) { + this.name = name; + this.type = type; + this.offset = 0; + this.address = address; + this.value = value; + } + + @Override + public String toString() { + String val = value == null ? "null" : String.format("0x%x", value); + return String.format("Field[name=%s, type=%s, offset=%d, address=0x%x, value=%s]", name, type, offset, address, val); + } +} diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/VMFlag.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/VMFlag.java Thu Jun 16 16:41:50 2016 +0000 @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2016, 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; + +/** + * Describes a VM flag exposed via {@link HotSpotVMConfigAccess}. + */ +public final class VMFlag { + + /** + * The name of the flag. + */ + public final String name; + + /** + * The C++ type of the flag. + */ + public final String type; + + /** + * The flag's value. + */ + public final Object value; + + VMFlag(String name, String type, Object value) { + this.name = name; + this.type = type; + this.value = value; + } + + @Override + public String toString() { + return String.format("Flag[type=%s, name=%s, value=%s]", type, name, value); + } +} diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/HotSpotJVMCICompilerFactory.java --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/HotSpotJVMCICompilerFactory.java Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/HotSpotJVMCICompilerFactory.java Thu Jun 16 16:41:50 2016 +0000 @@ -22,7 +22,6 @@ */ package jdk.vm.ci.hotspot.services; -import jdk.vm.ci.hotspot.HotSpotVMConfig; import jdk.vm.ci.runtime.services.JVMCICompilerFactory; /** @@ -42,35 +41,54 @@ return null; } + public enum CompilationLevelAdjustment { + /** + * No adjustment. + */ + None, + + /** + * Adjust based on declaring class of method. + */ + ByHolder, + + /** + * Adjust based on declaring class, name and signature of method. + */ + ByFullSignature + } + /** * Determines if this object may want to adjust the compilation level for a method that is being - * scheduled by the VM for compilation. The legal return values and their meanings are: - *
      - *
    • 0 - no adjustment
    • - *
    • 1 - adjust based on declaring class of method
    • - *
    • 2 - adjust based on declaring class, name and signature of method
    • - *
    + * scheduled by the VM for compilation. */ - public int getCompilationLevelAdjustment(HotSpotVMConfig config) { - return config.compLevelAdjustmentNone; + public CompilationLevelAdjustment getCompilationLevelAdjustment() { + return CompilationLevelAdjustment.None; + } + + public enum CompilationLevel { + None, + Simple, + LimitedProfile, + FullProfile, + FullOptimization } /** * Potentially modifies the compilation level currently selected by the VM compilation policy * for a method. * - * @param config object for reading HotSpot {@code CompLevel} enum values * @param declaringClass the class in which the method is declared * @param name the name of the method or {@code null} depending on the value that was returned - * by {@link #getCompilationLevelAdjustment(HotSpotVMConfig)} + * by {@link #getCompilationLevelAdjustment()} * @param signature the signature of the method or {@code null} depending on the value that was - * returned by {@link #getCompilationLevelAdjustment(HotSpotVMConfig)} + * returned by {@link #getCompilationLevelAdjustment()} * @param isOsr specifies if the compilation being scheduled in an OSR compilation * @param level the compilation level currently selected by the VM compilation policy * @return the compilation level to use for the compilation being scheduled (must be a valid * {@code CompLevel} enum value) */ - public int adjustCompilationLevel(HotSpotVMConfig config, Class declaringClass, String name, String signature, boolean isOsr, int level) { + public CompilationLevel adjustCompilationLevel(Class declaringClass, String name, String signature, boolean isOsr, CompilationLevel level) { throw new InternalError("Should not reach here"); } } diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspotvmconfig/src/jdk/vm/ci/hotspotvmconfig/HotSpotVMAddress.java --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspotvmconfig/src/jdk/vm/ci/hotspotvmconfig/HotSpotVMAddress.java Wed Jun 01 09:13:10 2016 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2015, 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.hotspotvmconfig; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Refers to a C++ address in the VM. - */ -@Target(ElementType.FIELD) -@Retention(RetentionPolicy.RUNTIME) -public @interface HotSpotVMAddress { - - /** - * Returns the name of the symbol this address is referring to. - * - * @return name of symbol of this address - */ - String name(); - - /** - * List of architectures where this constant is required. Names are derived from - * {@link HotSpotVMConfig#getHostArchitectureName()}. An empty list implies that the constant is - * required on all architectures. - */ - @SuppressWarnings("javadoc") - String[] archs() default {}; - - /** - * List of operating systems where this constant is required. Names are derived from - * {@link HotSpotVMConfig#getHostOSName()}. An empty list implies that the constant is required - * on all operating systems. - */ - @SuppressWarnings("javadoc") - String[] os() default {}; - -} diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspotvmconfig/src/jdk/vm/ci/hotspotvmconfig/HotSpotVMConstant.java --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspotvmconfig/src/jdk/vm/ci/hotspotvmconfig/HotSpotVMConstant.java Wed Jun 01 09:13:10 2016 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2013, 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.hotspotvmconfig; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Refers to a C++ constant in the VM. - */ -@Target(ElementType.FIELD) -@Retention(RetentionPolicy.RUNTIME) -public @interface HotSpotVMConstant { - - /** - * Returns the name of the constant. - * - * @return name of constant - */ - String name(); - - /** - * List of architectures where this constant is required. Names are derived from - * {@link HotSpotVMConfig#getHostArchitectureName()}. An empty list implies that the constant is - * required on all architectures. - */ - @SuppressWarnings("javadoc") - String[] archs() default {}; -} diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspotvmconfig/src/jdk/vm/ci/hotspotvmconfig/HotSpotVMData.java --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspotvmconfig/src/jdk/vm/ci/hotspotvmconfig/HotSpotVMData.java Wed Jun 01 09:13:10 2016 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2015, 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.hotspotvmconfig; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Refers to a entry in {@code gHotSpotVMData}. - */ -@Target(ElementType.FIELD) -@Retention(RetentionPolicy.RUNTIME) -public @interface HotSpotVMData { - - /** - * Returns the array index of this field. - * - * @return array index of field - */ - int index(); - -} diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspotvmconfig/src/jdk/vm/ci/hotspotvmconfig/HotSpotVMField.java --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspotvmconfig/src/jdk/vm/ci/hotspotvmconfig/HotSpotVMField.java Wed Jun 01 09:13:10 2016 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2013, 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.hotspotvmconfig; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Refers to a C++ field in the VM. - */ -@Target(ElementType.FIELD) -@Retention(RetentionPolicy.RUNTIME) -public @interface HotSpotVMField { - - /** - * Types of information this annotation can return. - */ - enum Type { - /** - * Returns the offset of this field within the type. Only valid for instance fields. - */ - OFFSET, - - /** - * Returns the absolute address of this field. Only valid for static fields. - */ - ADDRESS, - - /** - * Returns the value of this field. Only valid for static fields. - */ - VALUE; - } - - /** - * Specifies what type of information to return. - * - * @see Type - */ - Type get(); - - /** - * Returns the type name containing this field. - * - * @return name of containing type - */ - String type(); - - /** - * Returns the name of this field. - * - * @return name of field - */ - String name(); - - /** - * List of architectures where this constant is required. Names are derived from - * {@link HotSpotVMConfig#getHostArchitectureName()}. An empty list implies that the constant is - * required on all architectures. - */ - @SuppressWarnings("javadoc") - String[] archs() default {}; -} diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspotvmconfig/src/jdk/vm/ci/hotspotvmconfig/HotSpotVMFlag.java --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspotvmconfig/src/jdk/vm/ci/hotspotvmconfig/HotSpotVMFlag.java Wed Jun 01 09:13:10 2016 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2013, 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.hotspotvmconfig; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Refers to a C++ flag in the VM. - */ -@Target(ElementType.FIELD) -@Retention(RetentionPolicy.RUNTIME) -public @interface HotSpotVMFlag { - - /** - * Returns the name of this flag. - * - * @return name of flag. - */ - String name(); - - /** - * List of architectures where this constant is required. Names are derived from - * {@link HotSpotVMConfig#getHostArchitectureName()}. An empty list implies that the constant is - * required on all architectures. - */ - @SuppressWarnings("javadoc") - String[] archs() default {}; - - boolean optional() default false; -} diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspotvmconfig/src/jdk/vm/ci/hotspotvmconfig/HotSpotVMType.java --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspotvmconfig/src/jdk/vm/ci/hotspotvmconfig/HotSpotVMType.java Wed Jun 01 09:13:10 2016 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2013, 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.hotspotvmconfig; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Refers to a C++ type in the VM. - */ -@Target(ElementType.FIELD) -@Retention(RetentionPolicy.RUNTIME) -public @interface HotSpotVMType { - - /** - * Types of information this annotation can return. - */ - enum Type { - /** - * Returns the size of the type (C++ {@code sizeof()}). - */ - SIZE; - } - - /** - * Specifies what type of information to return. - * - * @see Type - */ - Type get(); - - /** - * Returns the name of the type. - * - * @return name of type - */ - String name(); -} diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp --- a/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp Thu Jun 16 16:41:50 2016 +0000 @@ -88,41 +88,6 @@ return NULL; } -extern "C" { -extern VMStructEntry* jvmciHotSpotVMStructs; -extern uint64_t jvmciHotSpotVMStructEntryTypeNameOffset; -extern uint64_t jvmciHotSpotVMStructEntryFieldNameOffset; -extern uint64_t jvmciHotSpotVMStructEntryTypeStringOffset; -extern uint64_t jvmciHotSpotVMStructEntryIsStaticOffset; -extern uint64_t jvmciHotSpotVMStructEntryOffsetOffset; -extern uint64_t jvmciHotSpotVMStructEntryAddressOffset; -extern uint64_t jvmciHotSpotVMStructEntryArrayStride; - -extern VMTypeEntry* jvmciHotSpotVMTypes; -extern uint64_t jvmciHotSpotVMTypeEntryTypeNameOffset; -extern uint64_t jvmciHotSpotVMTypeEntrySuperclassNameOffset; -extern uint64_t jvmciHotSpotVMTypeEntryIsOopTypeOffset; -extern uint64_t jvmciHotSpotVMTypeEntryIsIntegerTypeOffset; -extern uint64_t jvmciHotSpotVMTypeEntryIsUnsignedOffset; -extern uint64_t jvmciHotSpotVMTypeEntrySizeOffset; -extern uint64_t jvmciHotSpotVMTypeEntryArrayStride; - -extern VMIntConstantEntry* jvmciHotSpotVMIntConstants; -extern uint64_t jvmciHotSpotVMIntConstantEntryNameOffset; -extern uint64_t jvmciHotSpotVMIntConstantEntryValueOffset; -extern uint64_t jvmciHotSpotVMIntConstantEntryArrayStride; - -extern VMLongConstantEntry* jvmciHotSpotVMLongConstants; -extern uint64_t jvmciHotSpotVMLongConstantEntryNameOffset; -extern uint64_t jvmciHotSpotVMLongConstantEntryValueOffset; -extern uint64_t jvmciHotSpotVMLongConstantEntryArrayStride; - -extern VMAddressEntry* jvmciHotSpotVMAddresses; -extern uint64_t jvmciHotSpotVMAddressEntryNameOffset; -extern uint64_t jvmciHotSpotVMAddressEntryValueOffset; -extern uint64_t jvmciHotSpotVMAddressEntryArrayStride; -} - int CompilerToVM::Data::Klass_vtable_start_offset; int CompilerToVM::Data::Klass_vtable_length_offset; @@ -232,48 +197,151 @@ #undef SET_TRIGFUNC } -/** - * We put all jvmciHotSpotVM values in an array so we can read them easily from Java. - */ -static uintptr_t ciHotSpotVMData[28]; - -C2V_VMENTRY(jlong, initializeConfiguration, (JNIEnv *env, jobject)) - ciHotSpotVMData[0] = (uintptr_t) jvmciHotSpotVMStructs; - ciHotSpotVMData[1] = jvmciHotSpotVMStructEntryTypeNameOffset; - ciHotSpotVMData[2] = jvmciHotSpotVMStructEntryFieldNameOffset; - ciHotSpotVMData[3] = jvmciHotSpotVMStructEntryTypeStringOffset; - ciHotSpotVMData[4] = jvmciHotSpotVMStructEntryIsStaticOffset; - ciHotSpotVMData[5] = jvmciHotSpotVMStructEntryOffsetOffset; - ciHotSpotVMData[6] = jvmciHotSpotVMStructEntryAddressOffset; - ciHotSpotVMData[7] = jvmciHotSpotVMStructEntryArrayStride; - - ciHotSpotVMData[8] = (uintptr_t) jvmciHotSpotVMTypes; - ciHotSpotVMData[9] = jvmciHotSpotVMTypeEntryTypeNameOffset; - ciHotSpotVMData[10] = jvmciHotSpotVMTypeEntrySuperclassNameOffset; - ciHotSpotVMData[11] = jvmciHotSpotVMTypeEntryIsOopTypeOffset; - ciHotSpotVMData[12] = jvmciHotSpotVMTypeEntryIsIntegerTypeOffset; - ciHotSpotVMData[13] = jvmciHotSpotVMTypeEntryIsUnsignedOffset; - ciHotSpotVMData[14] = jvmciHotSpotVMTypeEntrySizeOffset; - ciHotSpotVMData[15] = jvmciHotSpotVMTypeEntryArrayStride; - - ciHotSpotVMData[16] = (uintptr_t) jvmciHotSpotVMIntConstants; - ciHotSpotVMData[17] = jvmciHotSpotVMIntConstantEntryNameOffset; - ciHotSpotVMData[18] = jvmciHotSpotVMIntConstantEntryValueOffset; - ciHotSpotVMData[19] = jvmciHotSpotVMIntConstantEntryArrayStride; - - ciHotSpotVMData[20] = (uintptr_t) jvmciHotSpotVMLongConstants; - ciHotSpotVMData[21] = jvmciHotSpotVMLongConstantEntryNameOffset; - ciHotSpotVMData[22] = jvmciHotSpotVMLongConstantEntryValueOffset; - ciHotSpotVMData[23] = jvmciHotSpotVMLongConstantEntryArrayStride; - - ciHotSpotVMData[24] = (uintptr_t) jvmciHotSpotVMAddresses; - ciHotSpotVMData[25] = jvmciHotSpotVMAddressEntryNameOffset; - ciHotSpotVMData[26] = jvmciHotSpotVMAddressEntryValueOffset; - ciHotSpotVMData[27] = jvmciHotSpotVMAddressEntryArrayStride; +C2V_VMENTRY(jobjectArray, readConfiguration, (JNIEnv *env)) +#define BOXED_LONG(name, value) oop name; do { jvalue p; p.j = (jlong) (value); name = java_lang_boxing_object::create(T_LONG, &p, CHECK_NULL);} while(0) +#define BOXED_DOUBLE(name, value) oop name; do { jvalue p; p.d = (jdouble) (value); name = java_lang_boxing_object::create(T_DOUBLE, &p, CHECK_NULL);} while(0) + ResourceMark rm; + HandleMark hm; CompilerToVM::Data::initialize(); - return (jlong) (address) &ciHotSpotVMData; + VMField::klass()->initialize(thread); + VMFlag::klass()->initialize(thread); + + int len = JVMCIVMStructs::localHotSpotVMStructs_count(); + objArrayHandle vmFields = oopFactory::new_objArray(VMField::klass(), len, CHECK_NULL); + for (int i = 0; i < len ; i++) { + VMStructEntry vmField = JVMCIVMStructs::localHotSpotVMStructs[i]; + instanceHandle vmFieldObj = InstanceKlass::cast(VMField::klass())->allocate_instance_handle(CHECK_NULL); + size_t name_buf_len = strlen(vmField.typeName) + strlen(vmField.fieldName) + 2 /* "::" */; + char* name_buf = NEW_RESOURCE_ARRAY(char, name_buf_len + 1); + sprintf(name_buf, "%s::%s", vmField.typeName, vmField.fieldName); + Handle name = java_lang_String::create_from_str(name_buf, CHECK_NULL); + Handle type = java_lang_String::create_from_str(vmField.typeString, CHECK_NULL); + VMField::set_name(vmFieldObj, name()); + VMField::set_type(vmFieldObj, type()); + VMField::set_offset(vmFieldObj, vmField.offset); + VMField::set_address(vmFieldObj, (jlong) vmField.address); + if (vmField.isStatic) { + if (strcmp(vmField.typeString, "bool") == 0) { + BOXED_LONG(value, *(jbyte*) vmField.address); + VMField::set_value(vmFieldObj, value); + } else if (strcmp(vmField.typeString, "int") == 0 || + strcmp(vmField.typeString, "jint") == 0) { + BOXED_LONG(value, *(jint*) vmField.address); + VMField::set_value(vmFieldObj, value); + } else if (strcmp(vmField.typeString, "uint64_t") == 0) { + BOXED_LONG(value, *(uint64_t*) vmField.address); + VMField::set_value(vmFieldObj, value); + } else if (strcmp(vmField.typeString, "address") == 0 || + strcmp(vmField.typeString, "intptr_t") == 0 || + strcmp(vmField.typeString, "uintptr_t") == 0 || + strcmp(vmField.typeString, "size_t") == 0 || + // All foo* types are addresses. + vmField.typeString[strlen(vmField.typeString) - 1] == '*') { + BOXED_LONG(value, *((address*) vmField.address)); + VMField::set_value(vmFieldObj, value); + } else { + JVMCI_ERROR_NULL("VM field %s has unsupported type %s", name_buf, vmField.typeString); + } + } + vmFields->obj_at_put(i, vmFieldObj()); + } + + len = JVMCIVMStructs::localHotSpotVMTypes_count(); + objArrayHandle vmTypes = oopFactory::new_objArray(SystemDictionary::Object_klass(), len * 2, CHECK_NULL); + for (int i = 0; i < len ; i++) { + VMTypeEntry vmType = JVMCIVMStructs::localHotSpotVMTypes[i]; + Handle name = java_lang_String::create_from_str(vmType.typeName, CHECK_NULL); + BOXED_LONG(size, vmType.size); + vmTypes->obj_at_put(i * 2, name()); + vmTypes->obj_at_put(i * 2 + 1, size); + } + + int ints_len = JVMCIVMStructs::localHotSpotVMIntConstants_count(); + int longs_len = JVMCIVMStructs::localHotSpotVMLongConstants_count(); + len = ints_len + longs_len; + objArrayHandle vmConstants = oopFactory::new_objArray(SystemDictionary::Object_klass(), len * 2, CHECK_NULL); + int insert = 0; + for (int i = 0; i < ints_len ; i++) { + VMIntConstantEntry c = JVMCIVMStructs::localHotSpotVMIntConstants[i]; + Handle name = java_lang_String::create_from_str(c.name, CHECK_NULL); + BOXED_LONG(value, c.value); + vmConstants->obj_at_put(insert++, name()); + vmConstants->obj_at_put(insert++, value); + } + for (int i = 0; i < longs_len ; i++) { + VMLongConstantEntry c = JVMCIVMStructs::localHotSpotVMLongConstants[i]; + Handle name = java_lang_String::create_from_str(c.name, CHECK_NULL); + BOXED_LONG(value, c.value); + vmConstants->obj_at_put(insert++, name()); + vmConstants->obj_at_put(insert++, value); + } + assert(insert == len * 2, "must be"); + + len = JVMCIVMStructs::localHotSpotVMAddresses_count(); + objArrayHandle vmAddresses = oopFactory::new_objArray(SystemDictionary::Object_klass(), len * 2, CHECK_NULL); + for (int i = 0; i < len ; i++) { + VMAddressEntry a = JVMCIVMStructs::localHotSpotVMAddresses[i]; + Handle name = java_lang_String::create_from_str(a.name, CHECK_NULL); + BOXED_LONG(value, a.value); + vmAddresses->obj_at_put(i * 2, name()); + vmAddresses->obj_at_put(i * 2 + 1, value); + } + + // The last entry is the null entry. + len = (int) Flag::numFlags - 1; + objArrayHandle vmFlags = oopFactory::new_objArray(VMFlag::klass(), len, CHECK_NULL); + for (int i = 0; i < len; i++) { + Flag* flag = &Flag::flags[i]; + instanceHandle vmFlagObj = InstanceKlass::cast(VMFlag::klass())->allocate_instance_handle(CHECK_NULL); + Handle name = java_lang_String::create_from_str(flag->_name, CHECK_NULL); + Handle type = java_lang_String::create_from_str(flag->_type, CHECK_NULL); + VMFlag::set_name(vmFlagObj, name()); + VMFlag::set_type(vmFlagObj, type()); + if (flag->is_bool()) { + BOXED_LONG(value, flag->get_bool()); + VMFlag::set_value(vmFlagObj, value); + } else if (flag->is_ccstr()) { + Handle value = java_lang_String::create_from_str(flag->get_ccstr(), CHECK_NULL); + VMFlag::set_value(vmFlagObj, value()); + } else if (flag->is_int()) { + BOXED_LONG(value, flag->get_int()); + VMFlag::set_value(vmFlagObj, value); + } else if (flag->is_intx()) { + BOXED_LONG(value, flag->get_intx()); + VMFlag::set_value(vmFlagObj, value); + } else if (flag->is_uint()) { + BOXED_LONG(value, flag->get_uint()); + VMFlag::set_value(vmFlagObj, value); + } else if (flag->is_uint64_t()) { + BOXED_LONG(value, flag->get_uint64_t()); + VMFlag::set_value(vmFlagObj, value); + } else if (flag->is_uintx()) { + BOXED_LONG(value, flag->get_uintx()); + VMFlag::set_value(vmFlagObj, value); + } else if (flag->is_double()) { + BOXED_DOUBLE(value, flag->get_double()); + VMFlag::set_value(vmFlagObj, value); + } else if (flag->is_size_t()) { + BOXED_LONG(value, flag->get_size_t()); + VMFlag::set_value(vmFlagObj, value); + } else { + JVMCI_ERROR_NULL("VM flag %s has unsupported type %s", flag->_name, flag->_type); + } + vmFlags->obj_at_put(i, vmFlagObj()); + } + + objArrayOop data = oopFactory::new_objArray(SystemDictionary::Object_klass(), 5, CHECK_NULL); + data->obj_at_put(0, vmFields()); + data->obj_at_put(1, vmTypes()); + data->obj_at_put(2, vmConstants()); + data->obj_at_put(3, vmAddresses()); + data->obj_at_put(4, vmFlags()); + + return (jobjectArray) JNIHandles::make_local(THREAD, data); +#undef BOXED_LONG +#undef BOXED_DOUBLE C2V_END C2V_VMENTRY(jbyteArray, getBytecode, (JNIEnv *, jobject, jobject jvmci_method)) @@ -1450,7 +1518,7 @@ {CC "getResolvedJavaMethod", CC "(Ljava/lang/Object;J)" HS_RESOLVED_METHOD, FN_PTR(getResolvedJavaMethod)}, {CC "getConstantPool", CC "(Ljava/lang/Object;J)" HS_CONSTANT_POOL, FN_PTR(getConstantPool)}, {CC "getResolvedJavaType", CC "(Ljava/lang/Object;JZ)" HS_RESOLVED_KLASS, FN_PTR(getResolvedJavaType)}, - {CC "initializeConfiguration", CC "(" HS_CONFIG ")J", FN_PTR(initializeConfiguration)}, + {CC "readConfiguration", CC "()[" OBJECT, FN_PTR(readConfiguration)}, {CC "installCode", CC "(" TARGET_DESCRIPTION HS_COMPILED_CODE INSTALLED_CODE HS_SPECULATION_LOG ")I", FN_PTR(installCode)}, {CC "getMetadata", CC "(" TARGET_DESCRIPTION HS_COMPILED_CODE HS_METADATA ")I", FN_PTR(getMetadata)}, {CC "resetCompilationStatistics", CC "()V", FN_PTR(resetCompilationStatistics)}, diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/share/vm/jvmci/jvmciJavaClasses.hpp --- a/hotspot/src/share/vm/jvmci/jvmciJavaClasses.hpp Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/src/share/vm/jvmci/jvmciJavaClasses.hpp Thu Jun 16 16:41:50 2016 +0000 @@ -112,6 +112,18 @@ start_class(HotSpotForeignCallTarget) \ long_field(HotSpotForeignCallTarget, address) \ end_class \ + start_class(VMField) \ + oop_field(VMField, name, "Ljava/lang/String;") \ + oop_field(VMField, type, "Ljava/lang/String;") \ + long_field(VMField, offset) \ + long_field(VMField, address) \ + oop_field(VMField, value, "Ljava/lang/Long;") \ + end_class \ + start_class(VMFlag) \ + oop_field(VMFlag, name, "Ljava/lang/String;") \ + oop_field(VMFlag, type, "Ljava/lang/String;") \ + oop_field(VMFlag, value, "Ljava/lang/Object;") \ + end_class \ start_class(Assumptions_NoFinalizableSubclass) \ oop_field(Assumptions_NoFinalizableSubclass, receiverType, "Ljdk/vm/ci/meta/ResolvedJavaType;") \ end_class \ diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/share/vm/jvmci/systemDictionary_jvmci.hpp --- a/hotspot/src/share/vm/jvmci/systemDictionary_jvmci.hpp Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/src/share/vm/jvmci/systemDictionary_jvmci.hpp Thu Jun 16 16:41:50 2016 +0000 @@ -49,6 +49,8 @@ do_klass(HotSpotJVMCIRuntime_klass, jdk_vm_ci_hotspot_HotSpotJVMCIRuntime, Jvmci) \ do_klass(HotSpotSpeculationLog_klass, jdk_vm_ci_hotspot_HotSpotSpeculationLog, Jvmci) \ do_klass(HotSpotCompilationRequestResult_klass, jdk_vm_ci_hotspot_HotSpotCompilationRequestResult, Jvmci) \ + do_klass(VMField_klass, jdk_vm_ci_hotspot_VMField, Jvmci) \ + do_klass(VMFlag_klass, jdk_vm_ci_hotspot_VMFlag, Jvmci) \ do_klass(Assumptions_ConcreteMethod_klass, jdk_vm_ci_meta_Assumptions_ConcreteMethod, Jvmci) \ do_klass(Assumptions_NoFinalizableSubclass_klass, jdk_vm_ci_meta_Assumptions_NoFinalizableSubclass, Jvmci) \ do_klass(Assumptions_ConcreteSubtype_klass, jdk_vm_ci_meta_Assumptions_ConcreteSubtype, Jvmci) \ diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/share/vm/jvmci/vmStructs_jvmci.cpp --- a/hotspot/src/share/vm/jvmci/vmStructs_jvmci.cpp Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/src/share/vm/jvmci/vmStructs_jvmci.cpp Thu Jun 16 16:41:50 2016 +0000 @@ -539,6 +539,8 @@ declare_function(SharedRuntime::exception_handler_for_return_address) \ declare_function(SharedRuntime::OSR_migration_end) \ declare_function(SharedRuntime::enable_stack_reserved_zone) \ + declare_function(SharedRuntime::frem) \ + declare_function(SharedRuntime::drem) \ \ declare_function(os::dll_load) \ declare_function(os::dll_lookup) \ @@ -733,22 +735,6 @@ #endif -// whole purpose of this function is to work around bug c++/27724 in gcc 4.1.1 -// with optimization turned on it doesn't affect produced code -static inline uint64_t cast_uint64_t(size_t x) -{ - return x; -} - -#define ASSIGN_CONST_TO_64BIT_VAR(var, expr) \ - JNIEXPORT uint64_t var = cast_uint64_t(expr); - -#define ASSIGN_OFFSET_TO_64BIT_VAR(var, type, field) \ - ASSIGN_CONST_TO_64BIT_VAR(var, offset_of(type, field)) - -#define ASSIGN_STRIDE_TO_64BIT_VAR(var, array) \ - ASSIGN_CONST_TO_64BIT_VAR(var, (char*)&array[1] - (char*)&array[0]) - // // Instantiation of VMStructEntries, VMTypeEntries and VMIntConstantEntries // @@ -871,37 +857,31 @@ GENERATE_VM_ADDRESS_LAST_ENTRY() }; +int JVMCIVMStructs::localHotSpotVMStructs_count() { + // Ignore sentinel entry at the end + return (sizeof(localHotSpotVMStructs) / sizeof(VMStructEntry)) - 1; +} +int JVMCIVMStructs::localHotSpotVMTypes_count() { + // Ignore sentinel entry at the end + return (sizeof(localHotSpotVMTypes) / sizeof(VMTypeEntry)) - 1; +} +int JVMCIVMStructs::localHotSpotVMIntConstants_count() { + // Ignore sentinel entry at the end + return (sizeof(localHotSpotVMIntConstants) / sizeof(VMIntConstantEntry)) - 1; +} +int JVMCIVMStructs::localHotSpotVMLongConstants_count() { + // Ignore sentinel entry at the end + return (sizeof(localHotSpotVMLongConstants) / sizeof(VMLongConstantEntry)) - 1; +} +int JVMCIVMStructs::localHotSpotVMAddresses_count() { + // Ignore sentinel entry at the end + return (sizeof(localHotSpotVMAddresses) / sizeof(VMAddressEntry)) - 1; +} + extern "C" { JNIEXPORT VMStructEntry* jvmciHotSpotVMStructs = JVMCIVMStructs::localHotSpotVMStructs; -ASSIGN_OFFSET_TO_64BIT_VAR(jvmciHotSpotVMStructEntryTypeNameOffset, VMStructEntry, typeName); -ASSIGN_OFFSET_TO_64BIT_VAR(jvmciHotSpotVMStructEntryFieldNameOffset, VMStructEntry, fieldName); -ASSIGN_OFFSET_TO_64BIT_VAR(jvmciHotSpotVMStructEntryTypeStringOffset, VMStructEntry, typeString); -ASSIGN_OFFSET_TO_64BIT_VAR(jvmciHotSpotVMStructEntryIsStaticOffset, VMStructEntry, isStatic); -ASSIGN_OFFSET_TO_64BIT_VAR(jvmciHotSpotVMStructEntryOffsetOffset, VMStructEntry, offset); -ASSIGN_OFFSET_TO_64BIT_VAR(jvmciHotSpotVMStructEntryAddressOffset, VMStructEntry, address); -ASSIGN_STRIDE_TO_64BIT_VAR(jvmciHotSpotVMStructEntryArrayStride, jvmciHotSpotVMStructs); - JNIEXPORT VMTypeEntry* jvmciHotSpotVMTypes = JVMCIVMStructs::localHotSpotVMTypes; -ASSIGN_OFFSET_TO_64BIT_VAR(jvmciHotSpotVMTypeEntryTypeNameOffset, VMTypeEntry, typeName); -ASSIGN_OFFSET_TO_64BIT_VAR(jvmciHotSpotVMTypeEntrySuperclassNameOffset, VMTypeEntry, superclassName); -ASSIGN_OFFSET_TO_64BIT_VAR(jvmciHotSpotVMTypeEntryIsOopTypeOffset, VMTypeEntry, isOopType); -ASSIGN_OFFSET_TO_64BIT_VAR(jvmciHotSpotVMTypeEntryIsIntegerTypeOffset, VMTypeEntry, isIntegerType); -ASSIGN_OFFSET_TO_64BIT_VAR(jvmciHotSpotVMTypeEntryIsUnsignedOffset, VMTypeEntry, isUnsigned); -ASSIGN_OFFSET_TO_64BIT_VAR(jvmciHotSpotVMTypeEntrySizeOffset, VMTypeEntry, size); -ASSIGN_STRIDE_TO_64BIT_VAR(jvmciHotSpotVMTypeEntryArrayStride, jvmciHotSpotVMTypes); - JNIEXPORT VMIntConstantEntry* jvmciHotSpotVMIntConstants = JVMCIVMStructs::localHotSpotVMIntConstants; -ASSIGN_OFFSET_TO_64BIT_VAR(jvmciHotSpotVMIntConstantEntryNameOffset, VMIntConstantEntry, name); -ASSIGN_OFFSET_TO_64BIT_VAR(jvmciHotSpotVMIntConstantEntryValueOffset, VMIntConstantEntry, value); -ASSIGN_STRIDE_TO_64BIT_VAR(jvmciHotSpotVMIntConstantEntryArrayStride, jvmciHotSpotVMIntConstants); - JNIEXPORT VMLongConstantEntry* jvmciHotSpotVMLongConstants = JVMCIVMStructs::localHotSpotVMLongConstants; -ASSIGN_OFFSET_TO_64BIT_VAR(jvmciHotSpotVMLongConstantEntryNameOffset, VMLongConstantEntry, name); -ASSIGN_OFFSET_TO_64BIT_VAR(jvmciHotSpotVMLongConstantEntryValueOffset, VMLongConstantEntry, value); -ASSIGN_STRIDE_TO_64BIT_VAR(jvmciHotSpotVMLongConstantEntryArrayStride, jvmciHotSpotVMLongConstants); - JNIEXPORT VMAddressEntry* jvmciHotSpotVMAddresses = JVMCIVMStructs::localHotSpotVMAddresses; -ASSIGN_OFFSET_TO_64BIT_VAR(jvmciHotSpotVMAddressEntryNameOffset, VMAddressEntry, name); -ASSIGN_OFFSET_TO_64BIT_VAR(jvmciHotSpotVMAddressEntryValueOffset, VMAddressEntry, value); -ASSIGN_STRIDE_TO_64BIT_VAR(jvmciHotSpotVMAddressEntryArrayStride, jvmciHotSpotVMAddresses); } diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/share/vm/jvmci/vmStructs_jvmci.hpp --- a/hotspot/src/share/vm/jvmci/vmStructs_jvmci.hpp Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/src/share/vm/jvmci/vmStructs_jvmci.hpp Thu Jun 16 16:41:50 2016 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 @@ -55,6 +55,12 @@ * Table of addresses. */ static VMAddressEntry localHotSpotVMAddresses[]; + + static int localHotSpotVMStructs_count(); + static int localHotSpotVMTypes_count(); + static int localHotSpotVMIntConstants_count(); + static int localHotSpotVMLongConstants_count(); + static int localHotSpotVMAddresses_count(); }; #endif // SHARE_VM_JVMCI_VMSTRUCTS_JVMCI_HPP diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/src/share/vm/jvmci/vmSymbols_jvmci.hpp --- a/hotspot/src/share/vm/jvmci/vmSymbols_jvmci.hpp Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/src/share/vm/jvmci/vmSymbols_jvmci.hpp Thu Jun 16 16:41:50 2016 +0000 @@ -50,6 +50,8 @@ template(jdk_vm_ci_hotspot_HotSpotJVMCIRuntime, "jdk/vm/ci/hotspot/HotSpotJVMCIRuntime") \ template(jdk_vm_ci_hotspot_HotSpotSpeculationLog, "jdk/vm/ci/hotspot/HotSpotSpeculationLog") \ template(jdk_vm_ci_hotspot_HotSpotCompilationRequestResult, "jdk/vm/ci/hotspot/HotSpotCompilationRequestResult") \ + template(jdk_vm_ci_hotspot_VMField, "jdk/vm/ci/hotspot/VMField") \ + template(jdk_vm_ci_hotspot_VMFlag, "jdk/vm/ci/hotspot/VMFlag") \ template(jdk_vm_ci_meta_JavaConstant, "jdk/vm/ci/meta/JavaConstant") \ template(jdk_vm_ci_meta_PrimitiveConstant, "jdk/vm/ci/meta/PrimitiveConstant") \ template(jdk_vm_ci_meta_RawConstant, "jdk/vm/ci/meta/RawConstant") \ diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/test/compiler/jvmci/common/patches/jdk.vm.ci/jdk/vm/ci/hotspot/CompilerToVMHelper.java --- a/hotspot/test/compiler/jvmci/common/patches/jdk.vm.ci/jdk/vm/ci/hotspot/CompilerToVMHelper.java Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/test/compiler/jvmci/common/patches/jdk.vm.ci/jdk/vm/ci/hotspot/CompilerToVMHelper.java Thu Jun 16 16:41:50 2016 +0000 @@ -152,8 +152,8 @@ CTVM.resetCompilationStatistics(); } - public static long initializeConfiguration(HotSpotVMConfig config) { - return CTVM.initializeConfiguration(config); + public static Object[] readConfiguration() { + return CTVM.readConfiguration(); } public static HotSpotResolvedJavaMethod resolveMethod( diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/test/compiler/jvmci/compilerToVM/InitializeConfigurationTest.java --- a/hotspot/test/compiler/jvmci/compilerToVM/InitializeConfigurationTest.java Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/test/compiler/jvmci/compilerToVM/InitializeConfigurationTest.java Thu Jun 16 16:41:50 2016 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -45,188 +45,30 @@ import java.util.function.Consumer; import jdk.vm.ci.hotspot.CompilerToVMHelper; import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime; +import jdk.vm.ci.hotspot.HotSpotVMConfigAccess; +import jdk.vm.ci.hotspot.HotSpotVMConfigStore; import jdk.test.lib.Asserts; import jdk.test.lib.Utils; import jdk.internal.misc.Unsafe; public class InitializeConfigurationTest { - private static final Unsafe UNSAFE = Utils.getUnsafe(); - public static void main(String args[]) { - new InitializeConfigurationTest().runTest(generateTestCases()); - } - - private static List generateTestCases() { - List result = new ArrayList<>(); - result.add(new TestCase("CodeCache", "_high_bound", "address", - InitializeConfigurationTest::verifyLongIsNotZero)); - result.add(new TestCase("StubRoutines", "_jint_arraycopy", "address", - InitializeConfigurationTest::verifyLongIsNotZero)); - return result; - } - - private static void verifyLongIsNotZero(Object o) { - Asserts.assertNotNull(o, "Got null value"); - Asserts.assertEQ(o.getClass(), Long.class, "Unexpected value type"); - Asserts.assertNE(o, 0L, "Got null address"); - } - - private void runTest(List tcases) { - VMStructDataReader reader = new VMStructDataReader( - CompilerToVMHelper.initializeConfiguration(HotSpotJVMCIRuntime.runtime().getConfig())); - while (reader.hasNext()) { - VMFieldData data = reader.next(); - for (TestCase tcase : tcases) { - tcase.check(data); - } - } - // now check if all passed - for (TestCase tcase: tcases) { - Asserts.assertTrue(tcase.isFound(), "Case failed: " + tcase); - } + new InitializeConfigurationTest().runTest(); } - private static class VMStructDataReader implements Iterator { - // see jvmciCompilerToVM:105 static uintptr_t ciHotSpotVMData[28]; - private static final int HOTSPOT_VM_DATA_INDEX_COUNT = 28; - private final long addresses[]; - private final long vmStructsBase; - private final long entityNameFieldOffset; - private final long nameFieldOffset; - private final long typeStringFieldOffset; - private final long addressOffset; - private final long entrySize; - private long nextElementAddress; - private VMFieldData nextElement; + private void runTest() { + TestHotSpotVMConfig config = new TestHotSpotVMConfig(HotSpotJVMCIRuntime.runtime().getConfigStore()); + Asserts.assertNE(config.codeCacheHighBound, 0L, "Got null address"); + Asserts.assertNE(config.stubRoutineJintArrayCopy, 0L, "Got null address"); + } - public VMStructDataReader(long gHotSpotVMData) { - Asserts.assertNE(gHotSpotVMData, 0L, "Got null base address"); - addresses = new long[HOTSPOT_VM_DATA_INDEX_COUNT]; - for (int i = 0; i < HOTSPOT_VM_DATA_INDEX_COUNT; i++) { - addresses[i] = UNSAFE.getAddress( - gHotSpotVMData + Unsafe.ADDRESS_SIZE * i); - } - vmStructsBase = addresses[0]; - entityNameFieldOffset = addresses[1]; - nameFieldOffset = addresses[2]; - typeStringFieldOffset = addresses[3]; - addressOffset = addresses[6]; - entrySize = addresses[7]; - nextElementAddress = vmStructsBase; - nextElement = read(); - } + private static class TestHotSpotVMConfig extends HotSpotVMConfigAccess { - @Override - public boolean hasNext() { - return nextElement != null; - } - - @Override - public VMFieldData next() { - if (nextElement == null) { - throw new NoSuchElementException("Next element is null"); - } - VMFieldData toReturn = nextElement; - nextElementAddress += entrySize; - nextElement = read(); - return toReturn; + private TestHotSpotVMConfig(HotSpotVMConfigStore store) { + super(store); } - private VMFieldData read() { - String entityFieldName = readCString( - UNSAFE.getAddress(nextElementAddress + nameFieldOffset)); - if (entityFieldName == null) { - return null; - } - String fieldType = readCString(UNSAFE.getAddress( - nextElementAddress + typeStringFieldOffset)); - String entityName = readCString(UNSAFE.getAddress( - nextElementAddress + entityNameFieldOffset)); - Object value; - if ("address".equals(fieldType)) { - long address = UNSAFE.getAddress( - nextElementAddress + addressOffset); - value = address; - } else { - // non-address cases are not supported - value = null; - } - return new VMFieldData(entityName, entityFieldName, fieldType, - value); - } - - private static String readCString(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(); - } - } - - private static class VMFieldData { - public final String entityFieldName; - public final String entityName; - public final String fieldType; - public final Object value; - - private VMFieldData(String entityName, String entityFieldName, - String fieldType, Object value) { - this.entityName = entityName; - this.entityFieldName = entityFieldName; - this.fieldType = fieldType; - this.value = value; - } - } - - private static class TestCase { - public final String entityName; - public final String fieldType; - public final String entityFieldName; - public final Consumer consumer; - private boolean found; - - public TestCase(String entityName, String entityFieldName, - String fieldType, Consumer predicate) { - Objects.requireNonNull(entityName, "Got null entityName"); - Objects.requireNonNull(entityFieldName, "Got null entityFieldName"); - Objects.requireNonNull(fieldType, "Got null type"); - if (!"address".equals(fieldType)) { - throw new Error("TESTBUG: unsupported testcase with fieldType=" - + fieldType); - } - this.entityName = entityName; - this.fieldType = fieldType; - this.entityFieldName = entityFieldName; - this.consumer = predicate; - this.found = false; - } - - public void check(VMFieldData data) { - if (entityFieldName.equals(data.entityFieldName) - && entityName.equals(data.entityName) - && fieldType.equals(data.fieldType)) { - Asserts.assertFalse(found, "Found 2 entries of " + this); - found = true; - consumer.accept(data.value); - } - } - - @Override - public String toString() { - return "CASE: entityName=" + entityName + " entityFieldName=" - + entityFieldName + " fieldType=" + fieldType; - } - - public boolean isFound() { - return found; - } + final long codeCacheHighBound = getFieldValue("CodeCache::_high_bound", Long.class); + final long stubRoutineJintArrayCopy = getFieldValue("StubRoutines::_jint_arraycopy", Long.class); } } diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/test/compiler/jvmci/errors/TestInvalidOopMap.java --- a/hotspot/test/compiler/jvmci/errors/TestInvalidOopMap.java Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/test/compiler/jvmci/errors/TestInvalidOopMap.java Thu Jun 16 16:41:50 2016 +0000 @@ -49,7 +49,6 @@ import jdk.vm.ci.common.JVMCIError; import jdk.vm.ci.hotspot.HotSpotCompiledCode.Comment; import jdk.vm.ci.hotspot.HotSpotReferenceMap; -import jdk.vm.ci.hotspot.HotSpotVMConfig; import jdk.vm.ci.meta.Assumptions.Assumption; import jdk.vm.ci.meta.JavaKind; import jdk.vm.ci.meta.PlatformKind; @@ -112,21 +111,4 @@ test(new HotSpotReferenceMap(oops, base, size, 8)); } - - @Test(expected = JVMCIError.class) - public void testInvalidNarrowDerivedOop() { - if (!HotSpotVMConfig.config().useCompressedOops) { - throw new JVMCIError("skipping test"); - } - - PlatformKind kind = arch.getPlatformKind(JavaKind.Int); - Register reg = getRegister(kind, 0); - Register baseReg = getRegister(arch.getPlatformKind(JavaKind.Object), 1); - - Location[] oops = new Location[]{Location.register(reg)}; - Location[] base = new Location[]{Location.register(baseReg)}; - int[] size = new int[]{kind.getSizeInBytes()}; - - test(new HotSpotReferenceMap(oops, base, size, 8)); - } } diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/CodeInstallationTest.java --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/CodeInstallationTest.java Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/CodeInstallationTest.java Thu Jun 16 16:41:50 2016 +0000 @@ -34,6 +34,7 @@ import jdk.vm.ci.code.test.amd64.AMD64TestAssembler; import jdk.vm.ci.code.test.sparc.SPARCTestAssembler; import jdk.vm.ci.hotspot.HotSpotCompiledCode; +import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime; import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; import jdk.vm.ci.meta.ConstantReflectionProvider; import jdk.vm.ci.meta.MetaAccessProvider; @@ -50,6 +51,7 @@ protected final CodeCacheProvider codeCache; protected final TargetDescription target; protected final ConstantReflectionProvider constantReflection; + protected final TestHotSpotVMConfig config; public CodeInstallationTest() { JVMCIBackend backend = JVMCI.getRuntime().getHostJVMCIBackend(); @@ -57,6 +59,7 @@ codeCache = backend.getCodeCache(); target = backend.getTarget(); constantReflection = backend.getConstantReflection(); + config = new TestHotSpotVMConfig(HotSpotJVMCIRuntime.runtime().getConfigStore()); } protected interface TestCompiler { @@ -67,9 +70,9 @@ private TestAssembler createAssembler() { Architecture arch = codeCache.getTarget().arch; if (arch instanceof AMD64) { - return new AMD64TestAssembler(codeCache); + return new AMD64TestAssembler(codeCache, config); } else if (arch instanceof SPARC) { - return new SPARCTestAssembler(codeCache); + return new SPARCTestAssembler(codeCache, config); } else { Assert.fail("unsupported architecture"); return null; diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DataPatchTest.java --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DataPatchTest.java Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DataPatchTest.java Thu Jun 16 16:41:50 2016 +0000 @@ -32,22 +32,20 @@ * jdk.vm.ci/jdk.vm.ci.runtime * jdk.vm.ci/jdk.vm.ci.amd64 * jdk.vm.ci/jdk.vm.ci.sparc - * @compile CodeInstallationTest.java DebugInfoTest.java TestAssembler.java amd64/AMD64TestAssembler.java sparc/SPARCTestAssembler.java + * @compile CodeInstallationTest.java DebugInfoTest.java TestAssembler.java TestHotSpotVMConfig.java amd64/AMD64TestAssembler.java sparc/SPARCTestAssembler.java * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.code.test.DataPatchTest */ package jdk.vm.ci.code.test; +import org.junit.Assume; +import org.junit.Test; + import jdk.vm.ci.code.Register; import jdk.vm.ci.code.site.DataSectionReference; import jdk.vm.ci.hotspot.HotSpotConstant; -import jdk.vm.ci.hotspot.HotSpotMetaAccessProvider; -import jdk.vm.ci.hotspot.HotSpotVMConfig; import jdk.vm.ci.meta.ResolvedJavaType; -import org.junit.Assume; -import org.junit.Test; - /** * Test code installation with data patches. */ @@ -73,12 +71,12 @@ @Test public void testInlineNarrowObject() { - Assume.assumeTrue(HotSpotVMConfig.config().useCompressedOops); + Assume.assumeTrue(config.useCompressedOops); test(asm -> { ResolvedJavaType type = metaAccess.lookupJavaType(getConstClass()); HotSpotConstant c = (HotSpotConstant) constantReflection.asJavaClass(type); Register compressed = asm.emitLoadPointer((HotSpotConstant) c.compress()); - Register ret = asm.emitUncompressPointer(compressed, HotSpotVMConfig.config().narrowOopBase, HotSpotVMConfig.config().narrowOopShift); + Register ret = asm.emitUncompressPointer(compressed, config.narrowOopBase, config.narrowOopShift); asm.emitPointerRet(ret); }); } @@ -96,14 +94,14 @@ @Test public void testNarrowDataSectionReference() { - Assume.assumeTrue(HotSpotVMConfig.config().useCompressedOops); + Assume.assumeTrue(config.useCompressedOops); test(asm -> { ResolvedJavaType type = metaAccess.lookupJavaType(getConstClass()); HotSpotConstant c = (HotSpotConstant) constantReflection.asJavaClass(type); HotSpotConstant cCompressed = (HotSpotConstant) c.compress(); DataSectionReference ref = asm.emitDataItem(cCompressed); Register compressed = asm.emitLoadNarrowPointer(ref); - Register ret = asm.emitUncompressPointer(compressed, HotSpotVMConfig.config().narrowOopBase, HotSpotVMConfig.config().narrowOopShift); + Register ret = asm.emitUncompressPointer(compressed, config.narrowOopBase, config.narrowOopShift); asm.emitPointerRet(ret); }); } @@ -113,20 +111,20 @@ test(asm -> { ResolvedJavaType type = metaAccess.lookupJavaType(getConstClass()); Register klass = asm.emitLoadPointer((HotSpotConstant) constantReflection.asObjectHub(type)); - Register ret = asm.emitLoadPointer(klass, HotSpotVMConfig.config().classMirrorOffset); + Register ret = asm.emitLoadPointer(klass, config.classMirrorOffset); asm.emitPointerRet(ret); }); } @Test public void testInlineNarrowMetadata() { - Assume.assumeTrue(HotSpotVMConfig.config().useCompressedClassPointers); + Assume.assumeTrue(config.useCompressedClassPointers); test(asm -> { ResolvedJavaType type = metaAccess.lookupJavaType(getConstClass()); HotSpotConstant hub = (HotSpotConstant) constantReflection.asObjectHub(type); Register narrowKlass = asm.emitLoadPointer((HotSpotConstant) hub.compress()); - Register klass = asm.emitUncompressPointer(narrowKlass, HotSpotVMConfig.config().narrowKlassBase, HotSpotVMConfig.config().narrowKlassShift); - Register ret = asm.emitLoadPointer(klass, HotSpotVMConfig.config().classMirrorOffset); + Register klass = asm.emitUncompressPointer(narrowKlass, config.narrowKlassBase, config.narrowKlassShift); + Register ret = asm.emitLoadPointer(klass, config.classMirrorOffset); asm.emitPointerRet(ret); }); } @@ -138,22 +136,22 @@ HotSpotConstant hub = (HotSpotConstant) constantReflection.asObjectHub(type); DataSectionReference ref = asm.emitDataItem(hub); Register klass = asm.emitLoadPointer(ref); - Register ret = asm.emitLoadPointer(klass, HotSpotVMConfig.config().classMirrorOffset); + Register ret = asm.emitLoadPointer(klass, config.classMirrorOffset); asm.emitPointerRet(ret); }); } @Test public void testNarrowMetadataInDataSection() { - Assume.assumeTrue(HotSpotVMConfig.config().useCompressedClassPointers); + Assume.assumeTrue(config.useCompressedClassPointers); test(asm -> { ResolvedJavaType type = metaAccess.lookupJavaType(getConstClass()); HotSpotConstant hub = (HotSpotConstant) constantReflection.asObjectHub(type); HotSpotConstant narrowHub = (HotSpotConstant) hub.compress(); DataSectionReference ref = asm.emitDataItem(narrowHub); Register narrowKlass = asm.emitLoadNarrowPointer(ref); - Register klass = asm.emitUncompressPointer(narrowKlass, HotSpotVMConfig.config().narrowKlassBase, HotSpotVMConfig.config().narrowKlassShift); - Register ret = asm.emitLoadPointer(klass, HotSpotVMConfig.config().classMirrorOffset); + Register klass = asm.emitUncompressPointer(narrowKlass, config.narrowKlassBase, config.narrowKlassShift); + Register ret = asm.emitLoadPointer(klass, config.classMirrorOffset); asm.emitPointerRet(ret); }); } diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleCodeInstallationTest.java --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleCodeInstallationTest.java Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleCodeInstallationTest.java Thu Jun 16 16:41:50 2016 +0000 @@ -32,7 +32,7 @@ * jdk.vm.ci/jdk.vm.ci.runtime * jdk.vm.ci/jdk.vm.ci.amd64 * jdk.vm.ci/jdk.vm.ci.sparc - * @compile CodeInstallationTest.java DebugInfoTest.java TestAssembler.java amd64/AMD64TestAssembler.java sparc/SPARCTestAssembler.java + * @compile CodeInstallationTest.java DebugInfoTest.java TestAssembler.java TestHotSpotVMConfig.java amd64/AMD64TestAssembler.java sparc/SPARCTestAssembler.java * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.code.test.SimpleCodeInstallationTest */ diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleDebugInfoTest.java --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleDebugInfoTest.java Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleDebugInfoTest.java Thu Jun 16 16:41:50 2016 +0000 @@ -32,7 +32,7 @@ * jdk.vm.ci/jdk.vm.ci.runtime * jdk.vm.ci/jdk.vm.ci.amd64 * jdk.vm.ci/jdk.vm.ci.sparc - * @compile CodeInstallationTest.java DebugInfoTest.java TestAssembler.java amd64/AMD64TestAssembler.java sparc/SPARCTestAssembler.java + * @compile CodeInstallationTest.java DebugInfoTest.java TestAssembler.java TestHotSpotVMConfig.java amd64/AMD64TestAssembler.java sparc/SPARCTestAssembler.java * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.code.test.SimpleDebugInfoTest */ @@ -43,7 +43,6 @@ import jdk.vm.ci.code.Register; import jdk.vm.ci.hotspot.HotSpotConstant; -import jdk.vm.ci.hotspot.HotSpotVMConfig; import jdk.vm.ci.meta.JavaConstant; import jdk.vm.ci.meta.JavaKind; import jdk.vm.ci.meta.ResolvedJavaType; @@ -255,7 +254,7 @@ @Test public void testRegNarrowObject() { - Assume.assumeTrue(HotSpotVMConfig.config().useCompressedOops); + Assume.assumeTrue(config.useCompressedOops); ResolvedJavaType type = metaAccess.lookupJavaType(objectOnStack()); DebugInfoCompiler compiler = (asm, values) -> { HotSpotConstant wide = (HotSpotConstant) constantReflection.asJavaClass(type); @@ -269,7 +268,7 @@ @Test public void testStackNarrowObject() { - Assume.assumeTrue(HotSpotVMConfig.config().useCompressedOops); + Assume.assumeTrue(config.useCompressedOops); ResolvedJavaType type = metaAccess.lookupJavaType(objectOnStack()); DebugInfoCompiler compiler = (asm, values) -> { HotSpotConstant wide = (HotSpotConstant) constantReflection.asJavaClass(type); diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/TestAssembler.java --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/TestAssembler.java Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/TestAssembler.java Thu Jun 16 16:41:50 2016 +0000 @@ -182,6 +182,7 @@ private final ArrayList dataPatches; protected final CodeCacheProvider codeCache; + protected final TestHotSpotVMConfig config; private final Register[] registers; private int nextRegister; @@ -204,7 +205,7 @@ } } - protected TestAssembler(CodeCacheProvider codeCache, int initialFrameSize, int stackAlignment, PlatformKind narrowOopKind, Register... registers) { + protected TestAssembler(CodeCacheProvider codeCache, TestHotSpotVMConfig config, int initialFrameSize, int stackAlignment, PlatformKind narrowOopKind, Register... registers) { this.narrowOopKind = new TestValueKind(narrowOopKind); this.code = new Buffer(); @@ -213,6 +214,7 @@ this.dataPatches = new ArrayList<>(); this.codeCache = codeCache; + this.config = config; this.registers = registers; this.nextRegister = 0; diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/TestHotSpotVMConfig.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/TestHotSpotVMConfig.java Thu Jun 16 16:41:50 2016 +0000 @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2016, 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.code.test; + +import jdk.vm.ci.hotspot.HotSpotVMConfigAccess; +import jdk.vm.ci.hotspot.HotSpotVMConfigStore; + +public class TestHotSpotVMConfig extends HotSpotVMConfigAccess { + + public TestHotSpotVMConfig(HotSpotVMConfigStore config) { + super(config); + } + + public final boolean useCompressedOops = getFlag("UseCompressedOops", Boolean.class); + public final boolean useCompressedClassPointers = getFlag("UseCompressedClassPointers", Boolean.class); + + public final long narrowOopBase = getFieldValue("CompilerToVM::Data::Universe_narrow_oop_base", Long.class, "address"); + public final int narrowOopShift = getFieldValue("CompilerToVM::Data::Universe_narrow_oop_shift", Integer.class, "int"); + + public final long narrowKlassBase = getFieldValue("CompilerToVM::Data::Universe_narrow_klass_base", Long.class, "address"); + public final int narrowKlassShift = getFieldValue("CompilerToVM::Data::Universe_narrow_klass_shift", Integer.class, "int"); + + public final int classMirrorOffset = getFieldOffset("Klass::_java_mirror", Integer.class, "oop"); + + public final int MARKID_DEOPT_HANDLER_ENTRY = getConstant("CodeInstaller::DEOPT_HANDLER_ENTRY", Integer.class); + public final long handleDeoptStub = getFieldValue("CompilerToVM::Data::SharedRuntime_deopt_blob_unpack", Long.class, "address"); +} diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/VirtualObjectDebugInfoTest.java --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/VirtualObjectDebugInfoTest.java Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/VirtualObjectDebugInfoTest.java Thu Jun 16 16:41:50 2016 +0000 @@ -32,7 +32,7 @@ * jdk.vm.ci/jdk.vm.ci.runtime * jdk.vm.ci/jdk.vm.ci.amd64 * jdk.vm.ci/jdk.vm.ci.sparc - * @compile CodeInstallationTest.java DebugInfoTest.java TestAssembler.java amd64/AMD64TestAssembler.java sparc/SPARCTestAssembler.java + * @compile CodeInstallationTest.java DebugInfoTest.java TestAssembler.java TestHotSpotVMConfig.java amd64/AMD64TestAssembler.java sparc/SPARCTestAssembler.java * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.code.test.VirtualObjectDebugInfoTest */ diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/amd64/AMD64TestAssembler.java --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/amd64/AMD64TestAssembler.java Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/amd64/AMD64TestAssembler.java Thu Jun 16 16:41:50 2016 +0000 @@ -32,17 +32,17 @@ import jdk.vm.ci.code.site.ConstantReference; import jdk.vm.ci.code.site.DataSectionReference; import jdk.vm.ci.code.test.TestAssembler; +import jdk.vm.ci.code.test.TestHotSpotVMConfig; import jdk.vm.ci.hotspot.HotSpotCallingConventionType; import jdk.vm.ci.hotspot.HotSpotConstant; import jdk.vm.ci.hotspot.HotSpotForeignCallTarget; -import jdk.vm.ci.hotspot.HotSpotVMConfig; import jdk.vm.ci.meta.JavaKind; import jdk.vm.ci.meta.VMConstant; public class AMD64TestAssembler extends TestAssembler { - public AMD64TestAssembler(CodeCacheProvider codeCache) { - super(codeCache, 16, 16, AMD64Kind.DWORD, AMD64.rax, AMD64.rcx, AMD64.rdi, AMD64.r8, AMD64.r9, AMD64.r10); + public AMD64TestAssembler(CodeCacheProvider codeCache, TestHotSpotVMConfig config) { + super(codeCache, config, 16, 16, AMD64Kind.DWORD, AMD64.rax, AMD64.rcx, AMD64.rdi, AMD64.r8, AMD64.r9, AMD64.r10); } private void emitFatNop() { @@ -68,7 +68,6 @@ @Override public void emitEpilogue() { - HotSpotVMConfig config = HotSpotVMConfig.config(); recordMark(config.MARKID_DEOPT_HANDLER_ENTRY); recordCall(new HotSpotForeignCallTarget(config.handleDeoptStub), 5, true, null); code.emitByte(0xE8); // CALL rel32 diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/sparc/SPARCTestAssembler.java --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/sparc/SPARCTestAssembler.java Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/sparc/SPARCTestAssembler.java Thu Jun 16 16:41:50 2016 +0000 @@ -30,12 +30,12 @@ import jdk.vm.ci.code.site.ConstantReference; import jdk.vm.ci.code.site.DataSectionReference; import jdk.vm.ci.code.test.TestAssembler; +import jdk.vm.ci.code.test.TestHotSpotVMConfig; import jdk.vm.ci.hotspot.HotSpotCallingConventionType; import jdk.vm.ci.hotspot.HotSpotCompiledCode; import jdk.vm.ci.hotspot.HotSpotConstant; import jdk.vm.ci.hotspot.HotSpotForeignCallTarget; import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; -import jdk.vm.ci.hotspot.HotSpotVMConfig; import jdk.vm.ci.meta.JavaKind; import jdk.vm.ci.meta.VMConstant; import jdk.vm.ci.sparc.SPARC; @@ -45,8 +45,8 @@ private static final int MASK13 = (1 << 13) - 1; - public SPARCTestAssembler(CodeCacheProvider codeCache) { - super(codeCache, 0, 16, SPARCKind.WORD, SPARC.l0, SPARC.l1, SPARC.l2, SPARC.l3, SPARC.l4, SPARC.l5, SPARC.l6, SPARC.l7); + public SPARCTestAssembler(CodeCacheProvider codeCache, TestHotSpotVMConfig config) { + super(codeCache, config, 0, 16, SPARCKind.WORD, SPARC.l0, SPARC.l1, SPARC.l2, SPARC.l3, SPARC.l4, SPARC.l5, SPARC.l6, SPARC.l7); } private void emitOp2(Register rd, int op2, int imm22) { @@ -74,7 +74,6 @@ @Override public void emitEpilogue() { - HotSpotVMConfig config = HotSpotVMConfig.config(); recordMark(config.MARKID_DEOPT_HANDLER_ENTRY); recordCall(new HotSpotForeignCallTarget(config.handleDeoptStub), 4, true, null); code.emitInt(1 << 30); // CALL diff -r 52e7ddc77845 -r 0f8dc3693499 hotspot/test/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MemoryAccessProviderData.java --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MemoryAccessProviderData.java Wed Jun 01 09:13:10 2016 +0300 +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MemoryAccessProviderData.java Thu Jun 16 16:41:50 2016 +0000 @@ -24,15 +24,18 @@ package jdk.vm.ci.hotspot.test; import java.lang.reflect.Field; + +import org.testng.annotations.DataProvider; + +import jdk.internal.misc.Unsafe; +import jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider; +import jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider; +import jdk.vm.ci.hotspot.HotSpotResolvedObjectType; +import jdk.vm.ci.hotspot.HotSpotVMConfigAccess; +import jdk.vm.ci.meta.Constant; import jdk.vm.ci.meta.JavaConstant; import jdk.vm.ci.meta.JavaKind; import jdk.vm.ci.runtime.JVMCI; -import org.testng.annotations.DataProvider; -import jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider; -import jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider; -import jdk.vm.ci.hotspot.HotSpotResolvedObjectType; -import jdk.vm.ci.meta.Constant; -import jdk.internal.misc.Unsafe; public class MemoryAccessProviderData { private static final Unsafe UNSAFE = getUnsafe(); @@ -54,7 +57,7 @@ @DataProvider(name = "positiveObject") public static Object[][] getPositiveObjectJavaKind() { HotSpotJVMCIRuntimeProvider runtime = (HotSpotJVMCIRuntimeProvider) JVMCI.getRuntime(); - int offset = runtime.getConfig().classMirrorOffset; + int offset = new HotSpotVMConfigAccess(runtime.getConfigStore()).getFieldOffset("Klass::_java_mirror", Integer.class, "oop"); Constant wrappedKlassPointer = ((HotSpotResolvedObjectType) runtime.fromClass(TestClass.class)).klass(); return new Object[][]{new Object[]{JavaKind.Object, wrappedKlassPointer, (long) offset, TEST_CLASS_CONSTANT, 0}}; }