# HG changeset patch # User Doug Simon # Date 1442581504 -7200 # Node ID 3884a98ebcde5c39379b6659bbf562a88ed0c714 # Parent 6a7f2f656ed99597674ea44413229663f198bb45 consistently use HotSpotVMConfig.config() for static access to the HotSpotVMConfig instance diff -r 6a7f2f656ed9 -r 3884a98ebcde jvmci/jdk.internal.jvmci.hotspot.jfr/src/jdk/internal/jvmci/hotspot/jfr/events/JFREventProvider.java --- a/jvmci/jdk.internal.jvmci.hotspot.jfr/src/jdk/internal/jvmci/hotspot/jfr/events/JFREventProvider.java Fri Sep 18 12:11:45 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.hotspot.jfr/src/jdk/internal/jvmci/hotspot/jfr/events/JFREventProvider.java Fri Sep 18 15:05:04 2015 +0200 @@ -22,9 +22,10 @@ */ package jdk.internal.jvmci.hotspot.jfr.events; +import static jdk.internal.jvmci.hotspot.HotSpotVMConfig.config; + import java.net.URISyntaxException; -import jdk.internal.jvmci.hotspot.HotSpotJVMCIRuntime; import jdk.internal.jvmci.hotspot.events.EmptyEventProvider.EmptyCompilationEvent; import jdk.internal.jvmci.hotspot.events.EmptyEventProvider.EmptyCompilerFailureEvent; import jdk.internal.jvmci.hotspot.events.EventProvider; @@ -49,7 +50,7 @@ @SuppressWarnings("unused") private final com.oracle.jrockit.jfr.Producer producer; public JFREventProvider() { - enabled = HotSpotJVMCIRuntime.runtime().getConfig().flightRecorder; + enabled = config().flightRecorder; com.oracle.jrockit.jfr.Producer p = null; if (enabled) { try { diff -r 6a7f2f656ed9 -r 3884a98ebcde jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotConstantPool.java --- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotConstantPool.java Fri Sep 18 12:11:45 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotConstantPool.java Fri Sep 18 15:05:04 2015 +0200 @@ -23,6 +23,7 @@ package jdk.internal.jvmci.hotspot; import static jdk.internal.jvmci.hotspot.HotSpotJVMCIRuntime.runtime; +import static jdk.internal.jvmci.hotspot.HotSpotVMConfig.config; import static jdk.internal.jvmci.hotspot.UnsafeAccess.UNSAFE; import java.lang.invoke.MethodHandle; @@ -128,10 +129,6 @@ this.tag = tag; } - private static HotSpotVMConfig config() { - return runtime().getConfig(); - } - /** * Maps JVM_CONSTANT tags to {@link JVM_CONSTANT} values. Using a separate class for lazy * initialization. @@ -211,7 +208,7 @@ * @return holder for this constant pool */ private HotSpotResolvedObjectType getHolder() { - return runtime().getCompilerToVM().getResolvedJavaType(this, runtime().getConfig().constantPoolHolderOffset, false); + return runtime().getCompilerToVM().getResolvedJavaType(this, config().constantPoolHolderOffset, false); } /** @@ -231,7 +228,7 @@ } else { assert opcode == Bytecodes.GETFIELD || opcode == Bytecodes.PUTFIELD || opcode == Bytecodes.GETSTATIC || opcode == Bytecodes.PUTSTATIC || opcode == Bytecodes.INVOKEINTERFACE || opcode == Bytecodes.INVOKEVIRTUAL || opcode == Bytecodes.INVOKESPECIAL || opcode == Bytecodes.INVOKESTATIC : "unexpected invoke opcode " + opcode; - index = rawIndex + runtime().getConfig().constantPoolCpCacheIndexTag; + index = rawIndex + config().constantPoolCpCacheIndexTag; } return index; } @@ -248,7 +245,7 @@ if (isInvokedynamicIndex(index)) { return decodeInvokedynamicIndex(index); } else { - return index - runtime().getConfig().constantPoolCpCacheIndexTag; + return index - config().constantPoolCpCacheIndexTag; } } @@ -283,7 +280,7 @@ */ private JVM_CONSTANT getTagAt(int index) { assertBounds(index); - HotSpotVMConfig config = runtime().getConfig(); + HotSpotVMConfig config = config(); final long metaspaceConstantPoolTags = UNSAFE.getAddress(getMetaspaceConstantPool() + config.constantPoolTagsOffset); final int tag = UNSAFE.getByteVolatile(null, metaspaceConstantPoolTags + config.arrayU1DataOffset + index); if (tag == 0) { @@ -300,7 +297,7 @@ */ private long getEntryAt(int index) { assertBounds(index); - return UNSAFE.getAddress(getMetaspaceConstantPool() + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); + return UNSAFE.getAddress(getMetaspaceConstantPool() + config().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); } /** @@ -311,7 +308,7 @@ */ private int getIntAt(int index) { assertTag(index, JVM_CONSTANT.Integer); - return UNSAFE.getInt(getMetaspaceConstantPool() + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); + return UNSAFE.getInt(getMetaspaceConstantPool() + config().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); } /** @@ -322,7 +319,7 @@ */ private long getLongAt(int index) { assertTag(index, JVM_CONSTANT.Long); - return UNSAFE.getLong(getMetaspaceConstantPool() + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); + return UNSAFE.getLong(getMetaspaceConstantPool() + config().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); } /** @@ -333,7 +330,7 @@ */ private float getFloatAt(int index) { assertTag(index, JVM_CONSTANT.Float); - return UNSAFE.getFloat(getMetaspaceConstantPool() + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); + return UNSAFE.getFloat(getMetaspaceConstantPool() + config().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); } /** @@ -344,7 +341,7 @@ */ private double getDoubleAt(int index) { assertTag(index, JVM_CONSTANT.Double); - return UNSAFE.getDouble(getMetaspaceConstantPool() + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); + return UNSAFE.getDouble(getMetaspaceConstantPool() + config().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); } /** @@ -355,7 +352,7 @@ */ private int getNameAndTypeAt(int index) { assertTag(index, JVM_CONSTANT.NameAndType); - return UNSAFE.getInt(getMetaspaceConstantPool() + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); + return UNSAFE.getInt(getMetaspaceConstantPool() + config().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); } /** @@ -436,7 +433,7 @@ */ private int getUncachedKlassRefIndexAt(int index) { assertTagIsFieldOrMethod(index); - final int refIndex = UNSAFE.getInt(getMetaspaceConstantPool() + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); + final int refIndex = UNSAFE.getInt(getMetaspaceConstantPool() + config().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); // klass ref index is in the low 16-bits. return refIndex & 0xFFFF; } @@ -474,7 +471,7 @@ @Override public int length() { - return UNSAFE.getInt(getMetaspaceConstantPool() + runtime().getConfig().constantPoolLengthOffset); + return UNSAFE.getInt(getMetaspaceConstantPool() + config().constantPoolLengthOffset); } @Override @@ -639,7 +636,7 @@ break; case Bytecodes.INVOKEDYNAMIC: { // invokedynamic instructions point to a constant pool cache entry. - index = decodeConstantPoolCacheIndex(cpi) + runtime().getConfig().constantPoolCpCacheIndexTag; + index = decodeConstantPoolCacheIndex(cpi) + config().constantPoolCpCacheIndexTag; index = runtime().getCompilerToVM().constantPoolRemapInstructionOperandFromCache(this, index); break; } diff -r 6a7f2f656ed9 -r 3884a98ebcde jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotJVMCIRuntime.java --- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotJVMCIRuntime.java Fri Sep 18 12:11:45 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotJVMCIRuntime.java Fri Sep 18 15:05:04 2015 +0200 @@ -101,7 +101,6 @@ * Gets the singleton {@link HotSpotJVMCIRuntime} object. */ public static HotSpotJVMCIRuntime runtime() { - assert DelayedInit.instance != null; return DelayedInit.instance; } diff -r 6a7f2f656ed9 -r 3884a98ebcde jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotMethodData.java --- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotMethodData.java Fri Sep 18 12:11:45 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotMethodData.java Fri Sep 18 15:05:04 2015 +0200 @@ -24,6 +24,7 @@ import static java.lang.String.format; import static jdk.internal.jvmci.hotspot.HotSpotJVMCIRuntime.runtime; +import static jdk.internal.jvmci.hotspot.HotSpotVMConfig.config; import static jdk.internal.jvmci.hotspot.UnsafeAccess.UNSAFE; import java.util.Arrays; @@ -44,7 +45,7 @@ */ public final class HotSpotMethodData { - private static final HotSpotVMConfig config = runtime().getConfig(); + private static final HotSpotVMConfig config = config(); private static final HotSpotMethodDataAccessor NO_DATA_NO_EXCEPTION_ACCESSOR = new NoMethodData(TriState.FALSE); private static final HotSpotMethodDataAccessor NO_DATA_EXCEPTION_POSSIBLY_NOT_RECORDED_ACCESSOR = new NoMethodData(TriState.UNKNOWN); diff -r 6a7f2f656ed9 -r 3884a98ebcde jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotMethodDataAccessor.java --- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotMethodDataAccessor.java Fri Sep 18 12:11:45 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotMethodDataAccessor.java Fri Sep 18 15:05:04 2015 +0200 @@ -22,7 +22,7 @@ */ package jdk.internal.jvmci.hotspot; -import static jdk.internal.jvmci.hotspot.HotSpotJVMCIRuntime.runtime; +import static jdk.internal.jvmci.hotspot.HotSpotVMConfig.config; import jdk.internal.jvmci.meta.JavaMethodProfile; import jdk.internal.jvmci.meta.JavaTypeProfile; import jdk.internal.jvmci.meta.ProfilingInfo; @@ -64,10 +64,6 @@ return value; } - private static HotSpotVMConfig config() { - return runtime().getConfig(); - } - public static Tag getEnum(int value) { Tag result = values()[value]; assert value == result.value; diff -r 6a7f2f656ed9 -r 3884a98ebcde jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotResolvedJavaFieldImpl.java --- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotResolvedJavaFieldImpl.java Fri Sep 18 12:11:45 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotResolvedJavaFieldImpl.java Fri Sep 18 15:05:04 2015 +0200 @@ -24,6 +24,7 @@ import static jdk.internal.jvmci.hotspot.HotSpotJVMCIRuntime.runtime; import static jdk.internal.jvmci.hotspot.HotSpotResolvedJavaFieldImpl.Options.ImplicitStableValues; +import static jdk.internal.jvmci.hotspot.HotSpotVMConfig.config; import java.lang.annotation.Annotation; import java.lang.reflect.Field; @@ -137,7 +138,7 @@ @Override public boolean isInternal() { - return (modifiers & runtime().getConfig().jvmAccFieldInternal) != 0; + return (modifiers & config().jvmAccFieldInternal) != 0; } /** @@ -190,7 +191,7 @@ @Override public boolean isSynthetic() { - return (runtime().getConfig().syntheticFlag & modifiers) != 0; + return (config().syntheticFlag & modifiers) != 0; } /** @@ -199,7 +200,7 @@ * @return true if field has {@link Stable} annotation, false otherwise */ public boolean isStable() { - if ((runtime().getConfig().jvmAccFieldStable & modifiers) != 0) { + if ((config().jvmAccFieldStable & modifiers) != 0) { return true; } assert getAnnotation(Stable.class) == null; diff -r 6a7f2f656ed9 -r 3884a98ebcde jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotResolvedJavaMethodImpl.java --- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotResolvedJavaMethodImpl.java Fri Sep 18 12:11:45 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotResolvedJavaMethodImpl.java Fri Sep 18 15:05:04 2015 +0200 @@ -24,6 +24,7 @@ import static jdk.internal.jvmci.hotspot.HotSpotJVMCIRuntime.runtime; import static jdk.internal.jvmci.hotspot.HotSpotResolvedJavaMethodImpl.Options.UseProfilingInformation; +import static jdk.internal.jvmci.hotspot.HotSpotVMConfig.config; import static jdk.internal.jvmci.hotspot.UnsafeAccess.UNSAFE; import java.lang.annotation.Annotation; @@ -93,7 +94,7 @@ * {@code metaspaceMethod} */ private static HotSpotResolvedObjectTypeImpl getHolder(long metaspaceMethod) { - HotSpotVMConfig config = runtime().getConfig(); + HotSpotVMConfig config = config(); final long metaspaceConstMethod = UNSAFE.getAddress(metaspaceMethod + config.methodConstMethodOffset); final long metaspaceConstantPool = UNSAFE.getAddress(metaspaceConstMethod + config.constMethodConstantsOffset); return runtime().getCompilerToVM().getResolvedJavaType(null, metaspaceConstantPool + config.constantPoolHolderOffset, false); @@ -121,7 +122,7 @@ this.metaspaceMethod = metaspaceMethod; this.holder = holder; - HotSpotVMConfig config = runtime().getConfig(); + HotSpotVMConfig config = config(); final long constMethod = getConstMethod(); /* @@ -153,7 +154,7 @@ */ private long getConstMethod() { assert metaspaceMethod != 0; - return UNSAFE.getAddress(metaspaceMethod + runtime().getConfig().methodConstMethodOffset); + return UNSAFE.getAddress(metaspaceMethod + config().methodConstMethodOffset); } @Override @@ -179,7 +180,7 @@ * @return flags of this method */ private int getFlags() { - return UNSAFE.getByte(metaspaceMethod + runtime().getConfig().methodFlagsOffset); + return UNSAFE.getByte(metaspaceMethod + config().methodFlagsOffset); } /** @@ -188,7 +189,7 @@ * @return flags of this method's ConstMethod */ private int getConstMethodFlags() { - return UNSAFE.getChar(getConstMethod() + runtime().getConfig().constMethodFlagsOffset); + return UNSAFE.getChar(getConstMethod() + config().constMethodFlagsOffset); } @Override @@ -221,7 +222,7 @@ * modifiers as well as the HotSpot internal modifiers. */ public int getAllModifiers() { - return UNSAFE.getInt(metaspaceMethod + runtime().getConfig().methodAccessFlagsOffset); + return UNSAFE.getInt(metaspaceMethod + config().methodAccessFlagsOffset); } @Override @@ -248,17 +249,17 @@ @Override public int getCodeSize() { - return UNSAFE.getChar(getConstMethod() + runtime().getConfig().constMethodCodeSizeOffset); + return UNSAFE.getChar(getConstMethod() + config().constMethodCodeSizeOffset); } @Override public ExceptionHandler[] getExceptionHandlers() { - final boolean hasExceptionTable = (getConstMethodFlags() & runtime().getConfig().constMethodHasExceptionTable) != 0; + final boolean hasExceptionTable = (getConstMethodFlags() & config().constMethodHasExceptionTable) != 0; if (!hasExceptionTable) { return new ExceptionHandler[0]; } - HotSpotVMConfig config = runtime().getConfig(); + HotSpotVMConfig config = config(); final int exceptionTableLength = runtime().getCompilerToVM().getExceptionTableLength(this); ExceptionHandler[] handlers = new ExceptionHandler[exceptionTableLength]; long exceptionTableElement = runtime().getCompilerToVM().getExceptionTableStart(this); @@ -300,7 +301,7 @@ * @return true if CallerSensitive annotation present, false otherwise */ public boolean isCallerSensitive() { - return (getFlags() & runtime().getConfig().methodFlagsCallerSensitive) != 0; + return (getFlags() & config().methodFlagsCallerSensitive) != 0; } /** @@ -309,7 +310,7 @@ * @return true if ForceInline annotation present, false otherwise */ public boolean isForceInline() { - return (getFlags() & runtime().getConfig().methodFlagsForceInline) != 0; + return (getFlags() & config().methodFlagsForceInline) != 0; } /** @@ -318,7 +319,7 @@ * @return true if DontInline annotation present, false otherwise */ public boolean isDontInline() { - return (getFlags() & runtime().getConfig().methodFlagsDontInline) != 0; + return (getFlags() & config().methodFlagsDontInline) != 0; } /** @@ -339,7 +340,7 @@ } public boolean hasBalancedMonitors() { - HotSpotVMConfig config = runtime().getConfig(); + HotSpotVMConfig config = config(); final int modifiers = getAllModifiers(); // Method has no monitorenter/exit bytecodes. @@ -371,7 +372,7 @@ if (isAbstract() || isNative()) { return 0; } - HotSpotVMConfig config = runtime().getConfig(); + HotSpotVMConfig config = config(); return UNSAFE.getChar(getConstMethod() + config.methodMaxLocalsOffset); } @@ -380,7 +381,7 @@ if (isAbstract() || isNative()) { return 0; } - HotSpotVMConfig config = runtime().getConfig(); + HotSpotVMConfig config = config(); return config.extraStackEntries + UNSAFE.getChar(getConstMethod() + config.constMethodMaxStackOffset); } @@ -424,7 +425,7 @@ * @return the value of {@code Method::_code} */ private long getCompiledCode() { - HotSpotVMConfig config = runtime().getConfig(); + HotSpotVMConfig config = config(); return UNSAFE.getAddress(metaspaceMethod + config.methodCodeOffset); } @@ -444,7 +445,7 @@ public boolean hasCompiledCodeAtLevel(int level) { long compiledCode = getCompiledCode(); if (compiledCode != 0) { - return UNSAFE.getInt(compiledCode + runtime().getConfig().nmethodCompLevelOffset) == level; + return UNSAFE.getInt(compiledCode + config().nmethodCompLevelOffset) == level; } return false; } @@ -456,7 +457,7 @@ ProfilingInfo info; if (UseProfilingInformation.getValue() && methodData == null) { - long metaspaceMethodData = UNSAFE.getAddress(metaspaceMethod + runtime().getConfig().methodDataOffset); + long metaspaceMethodData = UNSAFE.getAddress(metaspaceMethod + config().methodDataOffset); if (metaspaceMethodData != 0) { methodData = new HotSpotMethodData(metaspaceMethodData, this); if (TraceMethodDataFilter != null && this.format("%H.%n").contains(TraceMethodDataFilter)) { @@ -591,7 +592,7 @@ @Override public LineNumberTable getLineNumberTable() { - final boolean hasLineNumberTable = (getConstMethodFlags() & runtime().getConfig().constMethodHasLineNumberTable) != 0; + final boolean hasLineNumberTable = (getConstMethodFlags() & config().constMethodHasLineNumberTable) != 0; if (!hasLineNumberTable) { return null; } @@ -615,12 +616,12 @@ @Override public LocalVariableTable getLocalVariableTable() { - final boolean hasLocalVariableTable = (getConstMethodFlags() & runtime().getConfig().constMethodHasLocalVariableTable) != 0; + final boolean hasLocalVariableTable = (getConstMethodFlags() & config().constMethodHasLocalVariableTable) != 0; if (!hasLocalVariableTable) { return null; } - HotSpotVMConfig config = runtime().getConfig(); + HotSpotVMConfig config = config(); long localVariableTableElement = runtime().getCompilerToVM().getLocalVariableTableStart(this); final int localVariableTableLength = runtime().getCompilerToVM().getLocalVariableTableLength(this); Local[] locals = new Local[localVariableTableLength]; @@ -655,7 +656,7 @@ if (!isInVirtualMethodTable(resolved)) { throw new JVMCIError("%s does not have a vtable entry in type %s", this, resolved); } - HotSpotVMConfig config = runtime().getConfig(); + HotSpotVMConfig config = config(); final int vtableIndex = getVtableIndex((HotSpotResolvedObjectTypeImpl) resolved); return config.instanceKlassVtableStartOffset + vtableIndex * config.vtableEntrySize + config.vtableEntryMethodOffset; } @@ -672,11 +673,11 @@ private int getVtableIndex(HotSpotResolvedObjectTypeImpl resolved) { if (!holder.isLinked()) { - return runtime().getConfig().invalidVtableIndex; + return config().invalidVtableIndex; } if (holder.isInterface()) { if (resolved.isInterface()) { - return runtime().getConfig().invalidVtableIndex; + return config().invalidVtableIndex; } return getVtableIndexForInterface(resolved); } @@ -690,7 +691,7 @@ */ private int getVtableIndex() { assert !holder.isInterface(); - HotSpotVMConfig config = runtime().getConfig(); + HotSpotVMConfig config = config(); int result = UNSAFE.getInt(metaspaceMethod + config.methodVtableIndexOffset); assert result >= config.nonvirtualVtableIndex : "must be linked"; return result; @@ -731,7 +732,7 @@ } public int intrinsicId() { - HotSpotVMConfig config = runtime().getConfig(); + HotSpotVMConfig config = config(); return UNSAFE.getByte(metaspaceMethod + config.methodIntrinsicIdOffset) & 0xff; } @@ -767,7 +768,7 @@ } public boolean hasCodeAtLevel(int entryBCI, int level) { - if (entryBCI == runtime().getConfig().invocationEntryBci) { + if (entryBCI == config().invocationEntryBci) { return hasCompiledCodeAtLevel(level); } return runtime().getCompilerToVM().hasCompiledCodeForOSR(this, entryBCI, level); diff -r 6a7f2f656ed9 -r 3884a98ebcde jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotResolvedObjectTypeImpl.java --- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotResolvedObjectTypeImpl.java Fri Sep 18 12:11:45 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotResolvedObjectTypeImpl.java Fri Sep 18 15:05:04 2015 +0200 @@ -24,6 +24,7 @@ import static java.util.Objects.requireNonNull; import static jdk.internal.jvmci.hotspot.HotSpotJVMCIRuntime.runtime; +import static jdk.internal.jvmci.hotspot.HotSpotVMConfig.config; import static jdk.internal.jvmci.hotspot.UnsafeAccess.UNSAFE; import java.lang.annotation.Annotation; @@ -128,9 +129,9 @@ */ public long getMetaspaceKlass() { if (HotSpotJVMCIRuntime.getHostWordKind() == JavaKind.Long) { - return UNSAFE.getLong(javaClass, (long) runtime().getConfig().klassOffset); + return UNSAFE.getLong(javaClass, (long) config().klassOffset); } - return UNSAFE.getInt(javaClass, (long) runtime().getConfig().klassOffset) & 0xFFFFFFFFL; + return UNSAFE.getInt(javaClass, (long) config().klassOffset) & 0xFFFFFFFFL; } public long getMetaspacePointer() { @@ -147,7 +148,7 @@ } public int getAccessFlags() { - HotSpotVMConfig config = runtime().getConfig(); + HotSpotVMConfig config = config(); return UNSAFE.getInt(getMetaspaceKlass() + config.klassAccessFlagsOffset); } @@ -167,7 +168,7 @@ @Override public AssumptionResult findLeafConcreteSubtype() { - HotSpotVMConfig config = runtime().getConfig(); + HotSpotVMConfig config = config(); if (isArray()) { return getElementalType().isLeaf() ? new AssumptionResult<>(this) : null; } else if (isInterface()) { @@ -232,7 +233,7 @@ * @return value of the subklass field as metaspace klass pointer */ private HotSpotResolvedObjectTypeImpl getSubklass() { - return runtime().getCompilerToVM().getResolvedJavaType(this, runtime().getConfig().subklassOffset, false); + return runtime().getCompilerToVM().getResolvedJavaType(this, config().subklassOffset, false); } @Override @@ -322,7 +323,7 @@ @Override public boolean hasFinalizer() { - HotSpotVMConfig config = runtime().getConfig(); + HotSpotVMConfig config = config(); return (getAccessFlags() & config.klassHasFinalizerFlag) != 0; } @@ -338,12 +339,12 @@ @Override public boolean isInitialized() { - return isArray() ? true : getInitState() == runtime().getConfig().instanceKlassStateFullyInitialized; + return isArray() ? true : getInitState() == config().instanceKlassStateFullyInitialized; } @Override public boolean isLinked() { - return isArray() ? true : getInitState() >= runtime().getConfig().instanceKlassStateLinked; + return isArray() ? true : getInitState() >= config().instanceKlassStateLinked; } /** @@ -354,7 +355,7 @@ */ private int getInitState() { assert !isArray() : "_init_state only exists in InstanceKlass"; - return UNSAFE.getByte(getMetaspaceKlass() + runtime().getConfig().instanceKlassInitStateOffset) & 0xFF; + return UNSAFE.getByte(getMetaspaceKlass() + config().instanceKlassInitStateOffset) & 0xFF; } @Override @@ -428,7 +429,7 @@ public HotSpotConstantPool getConstantPool() { if (constantPool == null) { - constantPool = runtime().getCompilerToVM().getConstantPool(this, runtime().getConfig().instanceKlassConstantsOffset); + constantPool = runtime().getCompilerToVM().getConstantPool(this, config().instanceKlassConstantsOffset); } return constantPool; } @@ -442,7 +443,7 @@ assert !isArray(); assert !isInterface(); - HotSpotVMConfig config = runtime().getConfig(); + HotSpotVMConfig config = config(); final int layoutHelper = layoutHelper(); assert layoutHelper > config.klassLayoutHelperNeutralValue : "must be instance"; @@ -456,7 +457,7 @@ } public int layoutHelper() { - HotSpotVMConfig config = runtime().getConfig(); + HotSpotVMConfig config = config(); return UNSAFE.getInt(getMetaspaceKlass() + config.klassLayoutHelperOffset); } @@ -476,7 +477,7 @@ } public int getVtableLength() { - HotSpotVMConfig config = runtime().getConfig(); + HotSpotVMConfig config = config(); if (isInterface() || isArray()) { /* Everything has the core vtable of java.lang.Object */ return config.baseVtableLength; @@ -565,7 +566,7 @@ * @param index index to the fields array */ public FieldInfo(int index) { - HotSpotVMConfig config = runtime().getConfig(); + HotSpotVMConfig config = config(); // Get Klass::_fields final long metaspaceFields = UNSAFE.getAddress(getMetaspaceKlass() + config.instanceKlassFieldsOffset); assert config.fieldInfoFieldSlots == 6 : "revisit the field parsing code"; @@ -573,19 +574,19 @@ } private int getAccessFlags() { - return readFieldSlot(runtime().getConfig().fieldInfoAccessFlagsOffset); + return readFieldSlot(config().fieldInfoAccessFlagsOffset); } private int getNameIndex() { - return readFieldSlot(runtime().getConfig().fieldInfoNameIndexOffset); + return readFieldSlot(config().fieldInfoNameIndexOffset); } private int getSignatureIndex() { - return readFieldSlot(runtime().getConfig().fieldInfoSignatureIndexOffset); + return readFieldSlot(config().fieldInfoSignatureIndexOffset); } public int getOffset() { - HotSpotVMConfig config = runtime().getConfig(); + HotSpotVMConfig config = config(); final int lowPacked = readFieldSlot(config.fieldInfoLowPackedOffset); final int highPacked = readFieldSlot(config.fieldInfoHighPackedOffset); final int offset = ((highPacked << Short.SIZE) | lowPacked) >> config.fieldInfoTagSize; @@ -624,7 +625,7 @@ } private boolean isInternal() { - return (getAccessFlags() & runtime().getConfig().jvmAccFieldInternal) != 0; + return (getAccessFlags() & config().jvmAccFieldInternal) != 0; } public boolean isStatic() { @@ -632,7 +633,7 @@ } public boolean hasGenericSignature() { - return (getAccessFlags() & runtime().getConfig().jvmAccFieldHasGenericSignature) != 0; + return (getAccessFlags() & config().jvmAccFieldHasGenericSignature) != 0; } } @@ -725,7 +726,7 @@ * See {@code FieldStreamBase::init_generic_signature_start_slot} */ private int getFieldCount() { - HotSpotVMConfig config = runtime().getConfig(); + HotSpotVMConfig config = config(); final long metaspaceFields = UNSAFE.getAddress(getMetaspaceKlass() + config.instanceKlassFieldsOffset); int metaspaceFieldsLength = UNSAFE.getInt(metaspaceFields + config.arrayU1LengthOffset); int fieldCount = 0; @@ -747,7 +748,7 @@ @Override public String getSourceFileName() { - HotSpotVMConfig config = runtime().getConfig(); + HotSpotVMConfig config = config(); final int sourceFileNameIndex = UNSAFE.getChar(getMetaspaceKlass() + config.instanceKlassSourceFileNameIndexOffset); if (sourceFileNameIndex == 0) { return null; @@ -807,16 +808,16 @@ } public boolean isPrimaryType() { - return runtime().getConfig().secondarySuperCacheOffset != superCheckOffset(); + return config().secondarySuperCacheOffset != superCheckOffset(); } public int superCheckOffset() { - HotSpotVMConfig config = runtime().getConfig(); + HotSpotVMConfig config = config(); return UNSAFE.getInt(getMetaspaceKlass() + config.superCheckOffsetOffset); } public long prototypeMarkWord() { - HotSpotVMConfig config = runtime().getConfig(); + HotSpotVMConfig config = config(); if (isArray()) { return config.arrayPrototypeMarkWord(); } else { diff -r 6a7f2f656ed9 -r 3884a98ebcde jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotVMConfig.java --- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotVMConfig.java Fri Sep 18 12:11:45 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotVMConfig.java Fri Sep 18 15:05:04 2015 +0200 @@ -23,6 +23,7 @@ package jdk.internal.jvmci.hotspot; import static jdk.internal.jvmci.common.UnsafeUtil.readCString; +import static jdk.internal.jvmci.hotspot.HotSpotJVMCIRuntime.runtime; import static jdk.internal.jvmci.hotspot.UnsafeAccess.UNSAFE; import java.lang.reflect.Field; @@ -65,8 +66,11 @@ return false; } + /** + * Gets the configuration associated with the current {@link HotSpotJVMCIRuntime}. + */ public static HotSpotVMConfig config() { - return HotSpotJVMCIRuntime.runtime().getConfig(); + return runtime().getConfig(); } /**