8159167: [JVMCI] fix HotSpotVMConfig startup performance
Reviewed-by: iveresov
This commit is contained in:
parent
4dad69bb2e
commit
9f373603a0
@ -149,7 +149,6 @@ suite = {
|
||||
"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 @@ suite = {
|
||||
"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 @@ suite = {
|
||||
],
|
||||
},
|
||||
|
||||
"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 @@ suite = {
|
||||
"jdk.vm.ci.hotspot.sparc",
|
||||
],
|
||||
"distDependencies" : [
|
||||
"JVMCI_HOTSPOTVMCONFIG",
|
||||
"JVMCI_SERVICES",
|
||||
"JVMCI_API",
|
||||
],
|
||||
|
@ -38,24 +38,23 @@ import jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory;
|
||||
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<AArch64.CPUFeature> computeFeatures(@SuppressWarnings("unused") HotSpotVMConfig config) {
|
||||
protected EnumSet<AArch64.CPUFeature> computeFeatures(@SuppressWarnings("unused") AArch64HotSpotVMConfig config) {
|
||||
// Configure the feature set using the HotSpot flag settings.
|
||||
EnumSet<AArch64.CPUFeature> features = EnumSet.noneOf(AArch64.CPUFeature.class);
|
||||
return features;
|
||||
}
|
||||
|
||||
protected EnumSet<AArch64.Flag> computeFlags(@SuppressWarnings("unused") HotSpotVMConfig config) {
|
||||
protected EnumSet<AArch64.Flag> computeFlags(@SuppressWarnings("unused") AArch64HotSpotVMConfig config) {
|
||||
EnumSet<AArch64.Flag> 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 @@ public class AArch64HotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFac
|
||||
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 class AArch64HotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFac
|
||||
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 @@ public class AArch64HotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFac
|
||||
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);
|
||||
|
@ -67,7 +67,6 @@ import jdk.vm.ci.code.TargetDescription;
|
||||
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 @@ public class AArch64HotSpotRegisterConfig implements RegisterConfig {
|
||||
|
||||
private final Register[] allocatable;
|
||||
|
||||
private final int maxFrameSize;
|
||||
|
||||
/**
|
||||
* The caller saved registers always include all parameter registers.
|
||||
*/
|
||||
@ -92,10 +89,6 @@ public class AArch64HotSpotRegisterConfig implements RegisterConfig {
|
||||
|
||||
private final RegisterAttributes[] attributesMap;
|
||||
|
||||
public int getMaximumFrameSize() {
|
||||
return maxFrameSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Register[] getAllocatableRegisters() {
|
||||
return allocatable.clone();
|
||||
@ -160,14 +153,13 @@ public class AArch64HotSpotRegisterConfig implements RegisterConfig {
|
||||
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<Register> callerSaveSet = new HashSet<>();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* 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
|
||||
@ -20,41 +20,28 @@
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package jdk.vm.ci.hotspotvmconfig;
|
||||
package jdk.vm.ci.hotspot.aarch64;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import jdk.vm.ci.hotspot.HotSpotVMConfigAccess;
|
||||
import jdk.vm.ci.hotspot.HotSpotVMConfigStore;
|
||||
|
||||
/**
|
||||
* Refers to a C++ type in the VM.
|
||||
* Used to access native configuration details.
|
||||
*
|
||||
* All non-static, public fields in this class are so that they can be compiled as constants.
|
||||
*/
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface HotSpotVMType {
|
||||
class AArch64HotSpotVMConfig extends HotSpotVMConfigAccess {
|
||||
|
||||
/**
|
||||
* Types of information this annotation can return.
|
||||
*/
|
||||
enum Type {
|
||||
/**
|
||||
* Returns the size of the type (C++ {@code sizeof()}).
|
||||
*/
|
||||
SIZE;
|
||||
AArch64HotSpotVMConfig(HotSpotVMConfigStore config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies what type of information to return.
|
||||
*
|
||||
* @see Type
|
||||
* Maximum allowed size of allocated area for a frame.
|
||||
*/
|
||||
Type get();
|
||||
final int maxFrameSize = 16 * 1024;
|
||||
|
||||
/**
|
||||
* Returns the name of the type.
|
||||
*
|
||||
* @return name of type
|
||||
*/
|
||||
String name();
|
||||
final boolean linuxOs = System.getProperty("os.name", "").startsWith("Linux");
|
||||
|
||||
final boolean useCompressedOops = getFlag("UseCompressedOops", Boolean.class);
|
||||
}
|
@ -38,13 +38,12 @@ import jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory;
|
||||
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<AMD64.CPUFeature> computeFeatures(HotSpotVMConfig config) {
|
||||
protected EnumSet<AMD64.CPUFeature> computeFeatures(AMD64HotSpotVMConfig config) {
|
||||
// Configure the feature set using the HotSpot flag settings.
|
||||
EnumSet<AMD64.CPUFeature> features = EnumSet.noneOf(AMD64.CPUFeature.class);
|
||||
if ((config.vmVersionFeatures & config.amd643DNOWPREFETCH) != 0) {
|
||||
@ -128,7 +127,7 @@ public class AMD64HotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFacto
|
||||
return features;
|
||||
}
|
||||
|
||||
protected EnumSet<AMD64.Flag> computeFlags(HotSpotVMConfig config) {
|
||||
protected EnumSet<AMD64.Flag> computeFlags(AMD64HotSpotVMConfig config) {
|
||||
EnumSet<AMD64.Flag> flags = EnumSet.noneOf(AMD64.Flag.class);
|
||||
if (config.useCountLeadingZerosInstruction) {
|
||||
flags.add(AMD64.Flag.UseCountLeadingZerosInstruction);
|
||||
@ -139,7 +138,7 @@ public class AMD64HotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFacto
|
||||
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 @@ public class AMD64HotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFacto
|
||||
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 @@ public class AMD64HotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFacto
|
||||
|
||||
@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 @@ public class AMD64HotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFacto
|
||||
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);
|
||||
|
@ -59,7 +59,6 @@ import jdk.vm.ci.code.TargetDescription;
|
||||
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 @@ public class AMD64HotSpotRegisterConfig implements RegisterConfig {
|
||||
|
||||
private final Register[] allocatable;
|
||||
|
||||
private final int maxFrameSize;
|
||||
|
||||
/**
|
||||
* The caller saved registers always include all parameter registers.
|
||||
*/
|
||||
@ -84,10 +81,6 @@ public class AMD64HotSpotRegisterConfig implements RegisterConfig {
|
||||
|
||||
private final RegisterAttributes[] attributesMap;
|
||||
|
||||
public int getMaximumFrameSize() {
|
||||
return maxFrameSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Register[] getAllocatableRegisters() {
|
||||
return allocatable.clone();
|
||||
@ -146,16 +139,15 @@ public class AMD64HotSpotRegisterConfig implements RegisterConfig {
|
||||
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;
|
||||
|
@ -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);
|
||||
}
|
@ -37,14 +37,13 @@ import jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory;
|
||||
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 @@ public class SPARCHotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFacto
|
||||
return new HotSpotCodeCacheProvider(runtime, runtime.getConfig(), target, regConfig);
|
||||
}
|
||||
|
||||
protected EnumSet<CPUFeature> computeFeatures(HotSpotVMConfig config) {
|
||||
protected EnumSet<CPUFeature> computeFeatures(SPARCHotSpotVMConfig config) {
|
||||
EnumSet<CPUFeature> features = EnumSet.noneOf(CPUFeature.class);
|
||||
if ((config.vmVersionFeatures & config.sparcVis1Instructions) != 0) {
|
||||
features.add(CPUFeature.VIS1);
|
||||
@ -143,10 +142,11 @@ public class SPARCHotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFacto
|
||||
@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);
|
||||
|
@ -81,7 +81,6 @@ import jdk.vm.ci.code.TargetDescription;
|
||||
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 @@ public class SPARCHotSpotRegisterConfig implements RegisterConfig {
|
||||
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<Register> callerSaveSet = new HashSet<>();
|
||||
Collections.addAll(callerSaveSet, target.arch.getAvailableValueRegisters());
|
||||
for (Register cs : calleeSaveRegisters) {
|
||||
|
@ -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);
|
||||
}
|
@ -35,11 +35,9 @@ import jdk.vm.ci.code.InvalidInstalledCodeException;
|
||||
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 @@ final class CompilerToVM {
|
||||
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:
|
||||
*
|
||||
* <pre>
|
||||
* info = [
|
||||
* VMField[] vmFields,
|
||||
* [String name, Long size, ...] vmTypeSizes,
|
||||
* [String name, Long value, ...] vmConstants,
|
||||
* [String name, Long value, ...] vmAddresses,
|
||||
* VMFlag[] vmFlags
|
||||
* ]
|
||||
* </pre>
|
||||
*
|
||||
* @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 @@ final class CompilerToVM {
|
||||
* <li>{@link HotSpotVMConfig#localVariableTableElementLengthOffset}</li>
|
||||
* <li>{@link HotSpotVMConfig#localVariableTableElementNameCpIndexOffset}</li>
|
||||
* <li>{@link HotSpotVMConfig#localVariableTableElementDescriptorCpIndexOffset}</li>
|
||||
* <li>{@link HotSpotVMConfig#localVariableTableElementSignatureCpIndexOffset}
|
||||
* <li>{@link HotSpotVMConfig#localVariableTableElementSlotOffset}
|
||||
* <li>{@link HotSpotVMConfig#localVariableTableElementStartBciOffset}
|
||||
* </ul>
|
||||
|
@ -42,7 +42,7 @@ import jdk.vm.ci.meta.SpeculationLog;
|
||||
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;
|
||||
|
||||
|
@ -25,7 +25,6 @@ package jdk.vm.ci.hotspot;
|
||||
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;
|
||||
|
@ -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 @@ final class HotSpotJVMCICompilerConfig {
|
||||
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;
|
||||
|
@ -49,6 +49,7 @@ import jdk.vm.ci.common.InitTimer;
|
||||
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 @@ public final class HotSpotJVMCIRuntime implements HotSpotJVMCIRuntimeProvider {
|
||||
|
||||
protected final CompilerToVM compilerToVm;
|
||||
|
||||
protected final HotSpotVMConfigStore configStore;
|
||||
protected final HotSpotVMConfig config;
|
||||
private final JVMCIBackend hostBackend;
|
||||
|
||||
@ -244,7 +246,8 @@ public final class HotSpotJVMCIRuntime implements HotSpotJVMCIRuntimeProvider {
|
||||
compilerToVm = new CompilerToVM();
|
||||
|
||||
try (InitTimer t = timer("HotSpotVMConfig<init>")) {
|
||||
config = new HotSpotVMConfig(compilerToVm);
|
||||
configStore = new HotSpotVMConfigStore(compilerToVm);
|
||||
config = new HotSpotVMConfig(configStore);
|
||||
}
|
||||
|
||||
String hostArchitecture = config.getHostArchitectureName();
|
||||
@ -277,11 +280,24 @@ public final class HotSpotJVMCIRuntime implements HotSpotJVMCIRuntimeProvider {
|
||||
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 @@ public final class HotSpotJVMCIRuntime implements HotSpotJVMCIRuntimeProvider {
|
||||
return metaAccessContext.fromClass(javaClass);
|
||||
}
|
||||
|
||||
public HotSpotVMConfigStore getConfigStore() {
|
||||
return configStore;
|
||||
}
|
||||
|
||||
public HotSpotVMConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
@ -352,7 +372,35 @@ public final class HotSpotJVMCIRuntime implements HotSpotJVMCIRuntimeProvider {
|
||||
*/
|
||||
@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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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 @@ import jdk.vm.ci.runtime.JVMCIRuntime;
|
||||
*/
|
||||
public interface HotSpotJVMCIRuntimeProvider extends JVMCIRuntime {
|
||||
|
||||
HotSpotVMConfigStore getConfigStore();
|
||||
|
||||
HotSpotVMConfig getConfig();
|
||||
|
||||
CompilerToVM getCompilerToVM();
|
||||
|
@ -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 @@ import jdk.vm.ci.meta.MemoryAccessProvider;
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
@ -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 @@ class HotSpotMemoryAccessProviderImpl implements HotSpotMemoryAccessProvider {
|
||||
}
|
||||
|
||||
@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 @@ class HotSpotMemoryAccessProviderImpl implements HotSpotMemoryAccessProvider {
|
||||
}
|
||||
|
||||
@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;
|
||||
|
@ -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.annotation.Annotation;
|
||||
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;
|
||||
|
||||
/**
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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> T getConstant(String name, Class<T> 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> T getConstant(String name, Class<T> 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> T getFieldOffset(String name, Class<T> 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> T getFieldOffset(String name, Class<T> 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> T getFieldOffset(String name, Class<T> 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> T getFieldValue(String name, Class<T> 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> T getFieldValue(String name, Class<T> 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> T getFieldValue(String name, Class<T> 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> T getFlag(String name, Class<T> 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> T getFlag(String name, Class<T> 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 <T> Object convertValue(String name, Class<T> 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;
|
||||
}
|
||||
}
|
@ -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<String, Long> 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<String, Long> 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<String, Long> 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<String, VMFlag> 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<String, VMField> getFields() {
|
||||
return Collections.unmodifiableMap(vmFields);
|
||||
}
|
||||
|
||||
final HashMap<String, VMField> vmFields;
|
||||
final HashMap<String, Long> vmTypeSizes;
|
||||
final HashMap<String, Long> vmConstants;
|
||||
final HashMap<String, Long> vmAddresses;
|
||||
final HashMap<String, VMFlag> 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:
|
||||
*
|
||||
* <pre>
|
||||
* info = [
|
||||
* VMField[] vmFields,
|
||||
* [String name, Long size, ...] vmTypeSizes,
|
||||
* [String name, Long value, ...] vmConstants,
|
||||
* [String name, Long value, ...] vmAddresses,
|
||||
* VMFlag[] vmFlags
|
||||
* ]
|
||||
* </pre>
|
||||
*/
|
||||
@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<init> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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("<init>")) {
|
||||
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("<init>")) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* 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
|
||||
@ -20,25 +20,36 @@
|
||||
* 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;
|
||||
package jdk.vm.ci.hotspot;
|
||||
|
||||
/**
|
||||
* Refers to a entry in {@code gHotSpotVMData}.
|
||||
* Describes a VM flag exposed via {@link HotSpotVMConfigAccess}.
|
||||
*/
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface HotSpotVMData {
|
||||
public final class VMFlag {
|
||||
|
||||
/**
|
||||
* Returns the array index of this field.
|
||||
*
|
||||
* @return array index of field
|
||||
* The name of the flag.
|
||||
*/
|
||||
int index();
|
||||
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);
|
||||
}
|
||||
}
|
@ -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 @@ public abstract class HotSpotJVMCICompilerFactory extends JVMCICompilerFactory {
|
||||
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:
|
||||
* <ul>
|
||||
* <li>0 - no adjustment</li>
|
||||
* <li>1 - adjust based on declaring class of method</li>
|
||||
* <li>2 - adjust based on declaring class, name and signature of method</li>
|
||||
* </ul>
|
||||
* 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");
|
||||
}
|
||||
}
|
||||
|
@ -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 {};
|
||||
|
||||
}
|
@ -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 {};
|
||||
}
|
@ -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 {};
|
||||
}
|
@ -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;
|
||||
}
|
@ -88,41 +88,6 @@ oop CompilerToVM::get_jvmci_type(KlassHandle klass, TRAPS) {
|
||||
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 @@ void CompilerToVM::Data::initialize() {
|
||||
#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 @@ JNINativeMethod CompilerToVM::methods[] = {
|
||||
{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)},
|
||||
|
@ -112,6 +112,18 @@ class JVMCIJavaClasses : AllStatic {
|
||||
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 \
|
||||
|
@ -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) \
|
||||
|
@ -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 @@ VMAddressEntry JVMCIVMStructs::localHotSpotVMAddresses[] = {
|
||||
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);
|
||||
}
|
||||
|
@ -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 @@ public:
|
||||
* 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
|
||||
|
@ -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") \
|
||||
|
@ -152,8 +152,8 @@ public class CompilerToVMHelper {
|
||||
CTVM.resetCompilationStatistics();
|
||||
}
|
||||
|
||||
public static long initializeConfiguration(HotSpotVMConfig config) {
|
||||
return CTVM.initializeConfiguration(config);
|
||||
public static Object[] readConfiguration() {
|
||||
return CTVM.readConfiguration();
|
||||
}
|
||||
|
||||
public static HotSpotResolvedJavaMethod resolveMethod(
|
||||
|
@ -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.Objects;
|
||||
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());
|
||||
new InitializeConfigurationTest().runTest();
|
||||
}
|
||||
|
||||
private static List<TestCase> generateTestCases() {
|
||||
List<TestCase> 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 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");
|
||||
}
|
||||
|
||||
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 static class TestHotSpotVMConfig extends HotSpotVMConfigAccess {
|
||||
|
||||
private void runTest(List<TestCase> 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);
|
||||
}
|
||||
}
|
||||
|
||||
private static class VMStructDataReader implements Iterator<VMFieldData> {
|
||||
// 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;
|
||||
|
||||
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 TestHotSpotVMConfig(HotSpotVMConfigStore store) {
|
||||
super(store);
|
||||
}
|
||||
|
||||
@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 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);
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,6 @@ import jdk.vm.ci.code.site.Site;
|
||||
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 @@ public class TestInvalidOopMap extends CodeInstallerTest {
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ import jdk.vm.ci.code.TargetDescription;
|
||||
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 @@ public class CodeInstallationTest {
|
||||
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 @@ public class CodeInstallationTest {
|
||||
codeCache = backend.getCodeCache();
|
||||
target = backend.getTarget();
|
||||
constantReflection = backend.getConstantReflection();
|
||||
config = new TestHotSpotVMConfig(HotSpotJVMCIRuntime.runtime().getConfigStore());
|
||||
}
|
||||
|
||||
protected interface TestCompiler {
|
||||
@ -67,9 +70,9 @@ public class CodeInstallationTest {
|
||||
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;
|
||||
|
@ -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 @@ public class DataPatchTest extends CodeInstallationTest {
|
||||
|
||||
@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 @@ public class DataPatchTest extends CodeInstallationTest {
|
||||
|
||||
@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 @@ public class DataPatchTest extends CodeInstallationTest {
|
||||
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 @@ public class DataPatchTest extends CodeInstallationTest {
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
@ -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
|
||||
*/
|
||||
|
||||
|
@ -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 org.junit.Test;
|
||||
|
||||
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 @@ public class SimpleDebugInfoTest extends DebugInfoTest {
|
||||
|
||||
@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 @@ public class SimpleDebugInfoTest extends DebugInfoTest {
|
||||
|
||||
@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);
|
||||
|
@ -182,6 +182,7 @@ public abstract class TestAssembler {
|
||||
private final ArrayList<DataPatch> dataPatches;
|
||||
|
||||
protected final CodeCacheProvider codeCache;
|
||||
protected final TestHotSpotVMConfig config;
|
||||
|
||||
private final Register[] registers;
|
||||
private int nextRegister;
|
||||
@ -204,7 +205,7 @@ public abstract class TestAssembler {
|
||||
}
|
||||
}
|
||||
|
||||
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 @@ public abstract class TestAssembler {
|
||||
this.dataPatches = new ArrayList<>();
|
||||
|
||||
this.codeCache = codeCache;
|
||||
this.config = config;
|
||||
|
||||
this.registers = registers;
|
||||
this.nextRegister = 0;
|
||||
|
@ -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");
|
||||
}
|
@ -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
|
||||
*/
|
||||
|
||||
|
@ -32,17 +32,17 @@ import jdk.vm.ci.code.StackSlot;
|
||||
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 @@ public class AMD64TestAssembler extends TestAssembler {
|
||||
|
||||
@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
|
||||
|
@ -30,12 +30,12 @@ import jdk.vm.ci.code.StackSlot;
|
||||
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 @@ public class SPARCTestAssembler extends TestAssembler {
|
||||
|
||||
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 @@ public class SPARCTestAssembler extends TestAssembler {
|
||||
|
||||
@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
|
||||
|
@ -24,15 +24,18 @@
|
||||
package jdk.vm.ci.hotspot.test;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
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.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.internal.misc.Unsafe;
|
||||
import jdk.vm.ci.meta.JavaConstant;
|
||||
import jdk.vm.ci.meta.JavaKind;
|
||||
import jdk.vm.ci.runtime.JVMCI;
|
||||
|
||||
public class MemoryAccessProviderData {
|
||||
private static final Unsafe UNSAFE = getUnsafe();
|
||||
@ -54,7 +57,7 @@ public class MemoryAccessProviderData {
|
||||
@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}};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user