< prev index next >

src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantPool.java

Print this page

        

*** 20,41 **** * or visit www.oracle.com if you need additional information or have any * questions. */ package jdk.vm.ci.hotspot; ! import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.*; import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; ! import java.lang.invoke.*; ! import jdk.vm.ci.common.*; ! import jdk.vm.ci.meta.*; /** * Implementation of {@link ConstantPool} for HotSpot. */ ! public final class HotSpotConstantPool implements ConstantPool, HotSpotProxified, MetaspaceWrapperObject { /** * Subset of JVM bytecode opcodes used by {@link HotSpotConstantPool}. */ public static class Bytecodes { --- 20,50 ---- * or visit www.oracle.com if you need additional information or have any * questions. */ package jdk.vm.ci.hotspot; ! import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM; ! import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; ! import static jdk.vm.ci.hotspot.HotSpotVMConfig.config; import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; ! import java.lang.invoke.MethodHandle; ! import jdk.vm.ci.common.JVMCIError; ! import jdk.vm.ci.meta.ConstantPool; ! import jdk.vm.ci.meta.JavaConstant; ! import jdk.vm.ci.meta.JavaField; ! import jdk.vm.ci.meta.JavaMethod; ! import jdk.vm.ci.meta.JavaType; ! import jdk.vm.ci.meta.ResolvedJavaMethod; ! import jdk.vm.ci.meta.ResolvedJavaType; ! import jdk.vm.ci.meta.Signature; /** * Implementation of {@link ConstantPool} for HotSpot. */ ! final class HotSpotConstantPool implements ConstantPool, HotSpotProxified, MetaspaceWrapperObject { /** * Subset of JVM bytecode opcodes used by {@link HotSpotConstantPool}. */ public static class Bytecodes {
*** 119,132 **** private JVM_CONSTANT(int tag) { 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. */ static class TagValueMap { --- 128,137 ----
*** 202,212 **** * Gets the holder for this constant pool as {@link HotSpotResolvedObjectTypeImpl}. * * @return holder for this constant pool */ private HotSpotResolvedObjectType getHolder() { ! return runtime().getCompilerToVM().getResolvedJavaType(this, runtime().getConfig().constantPoolHolderOffset, false); } /** * Converts a raw index from the bytecodes to a constant pool index by adding a * {@link HotSpotVMConfig#constantPoolCpCacheIndexTag constant}. --- 207,217 ---- * Gets the holder for this constant pool as {@link HotSpotResolvedObjectTypeImpl}. * * @return holder for this constant pool */ private HotSpotResolvedObjectType getHolder() { ! return compilerToVM().getResolvedJavaType(this, config().constantPoolHolderOffset, false); } /** * Converts a raw index from the bytecodes to a constant pool index by adding a * {@link HotSpotVMConfig#constantPoolCpCacheIndexTag constant}.
*** 222,232 **** // See: ConstantPool::is_invokedynamic_index assert index < 0 : "not an invokedynamic constant pool index " + index; } 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; } return index; } /** --- 227,237 ---- // See: ConstantPool::is_invokedynamic_index assert index < 0 : "not an invokedynamic constant pool index " + index; } 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 + config().constantPoolCpCacheIndexTag; } return index; } /**
*** 239,249 **** */ private static int decodeConstantPoolCacheIndex(int index) { if (isInvokedynamicIndex(index)) { return decodeInvokedynamicIndex(index); } else { ! return index - runtime().getConfig().constantPoolCpCacheIndexTag; } } /** * See {@code ConstantPool::is_invokedynamic_index}. --- 244,254 ---- */ private static int decodeConstantPoolCacheIndex(int index) { if (isInvokedynamicIndex(index)) { return decodeInvokedynamicIndex(index); } else { ! return index - config().constantPoolCpCacheIndexTag; } } /** * See {@code ConstantPool::is_invokedynamic_index}.
*** 258,268 **** private static int decodeInvokedynamicIndex(int i) { assert isInvokedynamicIndex(i) : i; return ~i; } ! public long getMetaspaceConstantPool() { return metaspaceConstantPool; } public long getMetaspacePointer() { return getMetaspaceConstantPool(); --- 263,273 ---- private static int decodeInvokedynamicIndex(int i) { assert isInvokedynamicIndex(i) : i; return ~i; } ! long getMetaspaceConstantPool() { return metaspaceConstantPool; } public long getMetaspacePointer() { return getMetaspaceConstantPool();
*** 274,284 **** * @param index constant pool index * @return constant pool tag */ private JVM_CONSTANT getTagAt(int index) { assertBounds(index); ! HotSpotVMConfig config = runtime().getConfig(); final long metaspaceConstantPoolTags = UNSAFE.getAddress(getMetaspaceConstantPool() + config.constantPoolTagsOffset); final int tag = UNSAFE.getByteVolatile(null, metaspaceConstantPoolTags + config.arrayU1DataOffset + index); if (tag == 0) { return null; } --- 279,289 ---- * @param index constant pool index * @return constant pool tag */ private JVM_CONSTANT getTagAt(int index) { assertBounds(index); ! HotSpotVMConfig config = config(); final long metaspaceConstantPoolTags = UNSAFE.getAddress(getMetaspaceConstantPool() + config.constantPoolTagsOffset); final int tag = UNSAFE.getByteVolatile(null, metaspaceConstantPoolTags + config.arrayU1DataOffset + index); if (tag == 0) { return null; }
*** 291,378 **** * @param index constant pool index * @return constant pool entry */ private long getEntryAt(int index) { assertBounds(index); ! return UNSAFE.getAddress(getMetaspaceConstantPool() + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); } /** * Gets the integer constant pool entry at index {@code index}. * * @param index constant pool index * @return integer constant pool entry at index */ private int getIntAt(int index) { assertTag(index, JVM_CONSTANT.Integer); ! return UNSAFE.getInt(getMetaspaceConstantPool() + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); } /** * Gets the long constant pool entry at index {@code index}. * * @param index constant pool index * @return long constant pool entry */ private long getLongAt(int index) { assertTag(index, JVM_CONSTANT.Long); ! return UNSAFE.getLong(getMetaspaceConstantPool() + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); } /** * Gets the float constant pool entry at index {@code index}. * * @param index constant pool index * @return float constant pool entry */ private float getFloatAt(int index) { assertTag(index, JVM_CONSTANT.Float); ! return UNSAFE.getFloat(getMetaspaceConstantPool() + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); } /** * Gets the double constant pool entry at index {@code index}. * * @param index constant pool index * @return float constant pool entry */ private double getDoubleAt(int index) { assertTag(index, JVM_CONSTANT.Double); ! return UNSAFE.getDouble(getMetaspaceConstantPool() + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); } /** * Gets the {@code JVM_CONSTANT_NameAndType} constant pool entry at index {@code index}. * * @param index constant pool index * @return {@code JVM_CONSTANT_NameAndType} constant pool entry */ private int getNameAndTypeAt(int index) { assertTag(index, JVM_CONSTANT.NameAndType); ! return UNSAFE.getInt(getMetaspaceConstantPool() + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); } /** * Gets the {@code JVM_CONSTANT_NameAndType} reference index constant pool entry at index * {@code index}. * * @param index constant pool index * @return {@code JVM_CONSTANT_NameAndType} reference constant pool entry */ private int getNameAndTypeRefIndexAt(int index) { ! return runtime().getCompilerToVM().lookupNameAndTypeRefIndexInPool(this, index); } /** * Gets the name of a {@code JVM_CONSTANT_NameAndType} constant pool entry referenced by another * entry denoted by {@code which}. * * @param which constant pool index or constant pool cache index * @return name as {@link String} */ private String getNameOf(int which) { ! return runtime().getCompilerToVM().lookupNameInPool(this, which); } /** * Gets the name reference index of a {@code JVM_CONSTANT_NameAndType} constant pool entry at * index {@code index}. --- 296,383 ---- * @param index constant pool index * @return constant pool entry */ private long getEntryAt(int index) { assertBounds(index); ! return UNSAFE.getAddress(getMetaspaceConstantPool() + config().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); } /** * Gets the integer constant pool entry at index {@code index}. * * @param index constant pool index * @return integer constant pool entry at index */ private int getIntAt(int index) { assertTag(index, JVM_CONSTANT.Integer); ! return UNSAFE.getInt(getMetaspaceConstantPool() + config().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); } /** * Gets the long constant pool entry at index {@code index}. * * @param index constant pool index * @return long constant pool entry */ private long getLongAt(int index) { assertTag(index, JVM_CONSTANT.Long); ! return UNSAFE.getLong(getMetaspaceConstantPool() + config().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); } /** * Gets the float constant pool entry at index {@code index}. * * @param index constant pool index * @return float constant pool entry */ private float getFloatAt(int index) { assertTag(index, JVM_CONSTANT.Float); ! return UNSAFE.getFloat(getMetaspaceConstantPool() + config().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); } /** * Gets the double constant pool entry at index {@code index}. * * @param index constant pool index * @return float constant pool entry */ private double getDoubleAt(int index) { assertTag(index, JVM_CONSTANT.Double); ! return UNSAFE.getDouble(getMetaspaceConstantPool() + config().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); } /** * Gets the {@code JVM_CONSTANT_NameAndType} constant pool entry at index {@code index}. * * @param index constant pool index * @return {@code JVM_CONSTANT_NameAndType} constant pool entry */ private int getNameAndTypeAt(int index) { assertTag(index, JVM_CONSTANT.NameAndType); ! return UNSAFE.getInt(getMetaspaceConstantPool() + config().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); } /** * Gets the {@code JVM_CONSTANT_NameAndType} reference index constant pool entry at index * {@code index}. * * @param index constant pool index * @return {@code JVM_CONSTANT_NameAndType} reference constant pool entry */ private int getNameAndTypeRefIndexAt(int index) { ! return compilerToVM().lookupNameAndTypeRefIndexInPool(this, index); } /** * Gets the name of a {@code JVM_CONSTANT_NameAndType} constant pool entry referenced by another * entry denoted by {@code which}. * * @param which constant pool index or constant pool cache index * @return name as {@link String} */ private String getNameOf(int which) { ! return compilerToVM().lookupNameInPool(this, which); } /** * Gets the name reference index of a {@code JVM_CONSTANT_NameAndType} constant pool entry at * index {@code index}.
*** 392,402 **** * * @param which constant pool index or constant pool cache index * @return signature as {@link String} */ private String getSignatureOf(int which) { ! return runtime().getCompilerToVM().lookupSignatureInPool(this, which); } /** * Gets the signature reference index of a {@code JVM_CONSTANT_NameAndType} constant pool entry * at index {@code index}. --- 397,407 ---- * * @param which constant pool index or constant pool cache index * @return signature as {@link String} */ private String getSignatureOf(int which) { ! return compilerToVM().lookupSignatureInPool(this, which); } /** * Gets the signature reference index of a {@code JVM_CONSTANT_NameAndType} constant pool entry * at index {@code index}.
*** 415,450 **** * * @param index constant pool index * @return klass reference index */ private int getKlassRefIndexAt(int index) { ! return runtime().getCompilerToVM().lookupKlassRefIndexInPool(this, index); } /** * Gets the uncached klass reference index constant pool entry at index {@code index}. See: * {@code ConstantPool::uncached_klass_ref_index_at}. * * @param index constant pool index * @return klass reference index */ ! private int getUncachedKlassRefIndexAt(int index, JVM_CONSTANT tag) { ! int resultIndex; ! if (tag == JVM_CONSTANT.MethodRef || tag == JVM_CONSTANT.Fieldref || tag == JVM_CONSTANT.InterfaceMethodref) { assertTagIsFieldOrMethod(index); ! final int refIndex = UNSAFE.getInt(getMetaspaceConstantPool() + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); // klass ref index is in the low 16-bits. ! resultIndex = refIndex & 0xFFFF; ! } else { ! resultIndex = index; ! } ! ! // Read the tag only once because it could change between multiple reads. ! final JVM_CONSTANT klassTag = getTagAt(resultIndex); ! assert klassTag == JVM_CONSTANT.Class || klassTag == JVM_CONSTANT.UnresolvedClass || klassTag == JVM_CONSTANT.UnresolvedClassInError : klassTag; ! ! return resultIndex; } /** * Asserts that the constant pool index {@code index} is in the bounds of the constant pool. * --- 420,444 ---- * * @param index constant pool index * @return klass reference index */ private int getKlassRefIndexAt(int index) { ! return compilerToVM().lookupKlassRefIndexInPool(this, index); } /** * Gets the uncached klass reference index constant pool entry at index {@code index}. See: * {@code ConstantPool::uncached_klass_ref_index_at}. * * @param index constant pool index * @return klass reference index */ ! private int getUncachedKlassRefIndexAt(int index) { assertTagIsFieldOrMethod(index); ! 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; } /** * Asserts that the constant pool index {@code index} is in the bounds of the constant pool. *
*** 476,486 **** assert tagAt == JVM_CONSTANT.Fieldref || tagAt == JVM_CONSTANT.MethodRef || tagAt == JVM_CONSTANT.InterfaceMethodref : tagAt; } @Override public int length() { ! return UNSAFE.getInt(getMetaspaceConstantPool() + runtime().getConfig().constantPoolLengthOffset); } @Override public Object lookupConstant(int cpi) { assert cpi != 0; --- 470,480 ---- assert tagAt == JVM_CONSTANT.Fieldref || tagAt == JVM_CONSTANT.MethodRef || tagAt == JVM_CONSTANT.InterfaceMethodref : tagAt; } @Override public int length() { ! return UNSAFE.getInt(getMetaspaceConstantPool() + config().constantPoolLengthOffset); } @Override public Object lookupConstant(int cpi) { assert cpi != 0;
*** 503,529 **** /* * Normally, we would expect a String here, but anonymous classes can have * "pseudo strings" (arbitrary live objects) patched into a String entry. Such * entries do not have a symbol in the constant pool slot. */ ! Object string = runtime().getCompilerToVM().resolvePossiblyCachedConstantInPool(this, cpi); return HotSpotObjectConstantImpl.forObject(string); case MethodHandle: case MethodHandleInError: case MethodType: case MethodTypeInError: ! Object obj = runtime().getCompilerToVM().resolveConstantInPool(this, cpi); return HotSpotObjectConstantImpl.forObject(obj); default: throw new JVMCIError("Unknown constant pool tag %s", tag); } } @Override public String lookupUtf8(int cpi) { assertTag(cpi, JVM_CONSTANT.Utf8); ! return runtime().getCompilerToVM().getSymbol(getEntryAt(cpi)); } @Override public Signature lookupSignature(int cpi) { return new HotSpotSignature(runtime(), lookupUtf8(cpi)); --- 497,523 ---- /* * Normally, we would expect a String here, but anonymous classes can have * "pseudo strings" (arbitrary live objects) patched into a String entry. Such * entries do not have a symbol in the constant pool slot. */ ! Object string = compilerToVM().resolvePossiblyCachedConstantInPool(this, cpi); return HotSpotObjectConstantImpl.forObject(string); case MethodHandle: case MethodHandleInError: case MethodType: case MethodTypeInError: ! Object obj = compilerToVM().resolveConstantInPool(this, cpi); return HotSpotObjectConstantImpl.forObject(obj); default: throw new JVMCIError("Unknown constant pool tag %s", tag); } } @Override public String lookupUtf8(int cpi) { assertTag(cpi, JVM_CONSTANT.Utf8); ! return compilerToVM().getSymbol(getEntryAt(cpi)); } @Override public Signature lookupSignature(int cpi) { return new HotSpotSignature(runtime(), lookupUtf8(cpi));
*** 531,541 **** @Override public JavaConstant lookupAppendix(int cpi, int opcode) { assert Bytecodes.isInvoke(opcode); final int index = rawIndexToConstantPoolIndex(cpi, opcode); ! Object appendix = runtime().getCompilerToVM().lookupAppendixInPool(this, index); if (appendix == null) { return null; } else { return HotSpotObjectConstantImpl.forObject(appendix); } --- 525,535 ---- @Override public JavaConstant lookupAppendix(int cpi, int opcode) { assert Bytecodes.isInvoke(opcode); final int index = rawIndexToConstantPoolIndex(cpi, opcode); ! Object appendix = compilerToVM().lookupAppendixInPool(this, index); if (appendix == null) { return null; } else { return HotSpotObjectConstantImpl.forObject(appendix); }
*** 556,566 **** } @Override public JavaMethod lookupMethod(int cpi, int opcode) { final int index = rawIndexToConstantPoolIndex(cpi, opcode); ! final HotSpotResolvedJavaMethod method = runtime().getCompilerToVM().lookupMethodInPool(this, index, (byte) opcode); if (method != null) { return method; } else { // Get the method's name and signature. String name = getNameOf(index); --- 550,560 ---- } @Override public JavaMethod lookupMethod(int cpi, int opcode) { final int index = rawIndexToConstantPoolIndex(cpi, opcode); ! final HotSpotResolvedJavaMethod method = compilerToVM().lookupMethodInPool(this, index, (byte) opcode); if (method != null) { return method; } else { // Get the method's name and signature. String name = getNameOf(index);
*** 568,578 **** if (opcode == Bytecodes.INVOKEDYNAMIC) { HotSpotResolvedObjectType holder = HotSpotResolvedObjectTypeImpl.fromObjectClass(MethodHandle.class); return new HotSpotMethodUnresolved(name, signature, holder); } else { final int klassIndex = getKlassRefIndexAt(index); ! final Object type = runtime().getCompilerToVM().lookupKlassInPool(this, klassIndex); JavaType holder = getJavaType(type); return new HotSpotMethodUnresolved(name, signature, holder); } } } --- 562,572 ---- if (opcode == Bytecodes.INVOKEDYNAMIC) { HotSpotResolvedObjectType holder = HotSpotResolvedObjectTypeImpl.fromObjectClass(MethodHandle.class); return new HotSpotMethodUnresolved(name, signature, holder); } else { final int klassIndex = getKlassRefIndexAt(index); ! final Object type = compilerToVM().lookupKlassInPool(this, klassIndex); JavaType holder = getJavaType(type); return new HotSpotMethodUnresolved(name, signature, holder); } } }
*** 581,591 **** public JavaType lookupType(int cpi, int opcode) { final LookupTypeCacheElement elem = this.lastLookupType; if (elem != null && elem.lastCpi == cpi) { return elem.javaType; } else { ! final Object type = runtime().getCompilerToVM().lookupKlassInPool(this, cpi); JavaType result = getJavaType(type); if (result instanceof ResolvedJavaType) { this.lastLookupType = new LookupTypeCacheElement(cpi, result); } return result; --- 575,585 ---- public JavaType lookupType(int cpi, int opcode) { final LookupTypeCacheElement elem = this.lastLookupType; if (elem != null && elem.lastCpi == cpi) { return elem.javaType; } else { ! final Object type = compilerToVM().lookupKlassInPool(this, cpi); JavaType result = getJavaType(type); if (result instanceof ResolvedJavaType) { this.lastLookupType = new LookupTypeCacheElement(cpi, result); } return result;
*** 607,617 **** if (holder instanceof HotSpotResolvedObjectTypeImpl) { long[] info = new long[2]; HotSpotResolvedObjectTypeImpl resolvedHolder; try { ! resolvedHolder = runtime().getCompilerToVM().resolveFieldInPool(this, index, (byte) opcode, info); } catch (Throwable t) { /* * If there was an exception resolving the field we give up and return an unresolved * field. */ --- 601,611 ---- if (holder instanceof HotSpotResolvedObjectTypeImpl) { long[] info = new long[2]; HotSpotResolvedObjectTypeImpl resolvedHolder; try { ! resolvedHolder = compilerToVM().resolveFieldInPool(this, index, (byte) opcode, info); } catch (Throwable t) { /* * If there was an exception resolving the field we give up and return an unresolved * field. */
*** 641,652 **** case Bytecodes.LDC2_W: index = cpi; break; case Bytecodes.INVOKEDYNAMIC: { // invokedynamic instructions point to a constant pool cache entry. ! index = decodeConstantPoolCacheIndex(cpi) + runtime().getConfig().constantPoolCpCacheIndexTag; ! index = runtime().getCompilerToVM().constantPoolRemapInstructionOperandFromCache(this, index); break; } case Bytecodes.GETSTATIC: case Bytecodes.PUTSTATIC: case Bytecodes.GETFIELD: --- 635,646 ---- case Bytecodes.LDC2_W: index = cpi; break; case Bytecodes.INVOKEDYNAMIC: { // invokedynamic instructions point to a constant pool cache entry. ! index = decodeConstantPoolCacheIndex(cpi) + config().constantPoolCpCacheIndexTag; ! index = compilerToVM().constantPoolRemapInstructionOperandFromCache(this, index); break; } case Bytecodes.GETSTATIC: case Bytecodes.PUTSTATIC: case Bytecodes.GETFIELD:
*** 655,665 **** case Bytecodes.INVOKESPECIAL: case Bytecodes.INVOKESTATIC: case Bytecodes.INVOKEINTERFACE: { // invoke and field instructions point to a constant pool cache entry. index = rawIndexToConstantPoolIndex(cpi, opcode); ! index = runtime().getCompilerToVM().constantPoolRemapInstructionOperandFromCache(this, index); break; } default: throw JVMCIError.shouldNotReachHere("Unexpected opcode " + opcode); } --- 649,659 ---- case Bytecodes.INVOKESPECIAL: case Bytecodes.INVOKESTATIC: case Bytecodes.INVOKEINTERFACE: { // invoke and field instructions point to a constant pool cache entry. index = rawIndexToConstantPoolIndex(cpi, opcode); ! index = compilerToVM().constantPoolRemapInstructionOperandFromCache(this, index); break; } default: throw JVMCIError.shouldNotReachHere("Unexpected opcode " + opcode); }
*** 671,712 **** } switch (tag) { case MethodRef: case Fieldref: case InterfaceMethodref: case Class: case UnresolvedClass: case UnresolvedClassInError: ! index = getUncachedKlassRefIndexAt(index, tag); ! final HotSpotResolvedObjectTypeImpl type = runtime().getCompilerToVM().resolveTypeInPool(this, index); Class<?> klass = type.mirror(); if (!klass.isPrimitive() && !klass.isArray()) { UNSAFE.ensureClassInitialized(klass); } switch (tag) { case MethodRef: if (Bytecodes.isInvokeHandleAlias(opcode)) { final int methodRefCacheIndex = rawIndexToConstantPoolIndex(cpi, opcode); if (isInvokeHandle(methodRefCacheIndex, type)) { ! runtime().getCompilerToVM().resolveInvokeHandleInPool(this, methodRefCacheIndex); } } } break; case InvokeDynamic: if (isInvokedynamicIndex(cpi)) { ! runtime().getCompilerToVM().resolveInvokeDynamicInPool(this, cpi); } break; default: // nothing break; } } private boolean isInvokeHandle(int methodRefCacheIndex, HotSpotResolvedObjectTypeImpl klass) { ! assertTag(runtime().getCompilerToVM().constantPoolRemapInstructionOperandFromCache(this, methodRefCacheIndex), JVM_CONSTANT.MethodRef); return ResolvedJavaMethod.isSignaturePolymorphic(klass, getNameOf(methodRefCacheIndex), runtime().getHostJVMCIBackend().getMetaAccess()); } @Override public String toString() { --- 665,710 ---- } switch (tag) { case MethodRef: case Fieldref: case InterfaceMethodref: + index = getUncachedKlassRefIndexAt(index); + // Read the tag only once because it could change between multiple reads. + final JVM_CONSTANT klassTag = getTagAt(index); + assert klassTag == JVM_CONSTANT.Class || klassTag == JVM_CONSTANT.UnresolvedClass || klassTag == JVM_CONSTANT.UnresolvedClassInError : klassTag; + // fall through case Class: case UnresolvedClass: case UnresolvedClassInError: ! final HotSpotResolvedObjectTypeImpl type = compilerToVM().resolveTypeInPool(this, index); Class<?> klass = type.mirror(); if (!klass.isPrimitive() && !klass.isArray()) { UNSAFE.ensureClassInitialized(klass); } switch (tag) { case MethodRef: if (Bytecodes.isInvokeHandleAlias(opcode)) { final int methodRefCacheIndex = rawIndexToConstantPoolIndex(cpi, opcode); if (isInvokeHandle(methodRefCacheIndex, type)) { ! compilerToVM().resolveInvokeHandleInPool(this, methodRefCacheIndex); } } } break; case InvokeDynamic: if (isInvokedynamicIndex(cpi)) { ! compilerToVM().resolveInvokeDynamicInPool(this, cpi); } break; default: // nothing break; } } private boolean isInvokeHandle(int methodRefCacheIndex, HotSpotResolvedObjectTypeImpl klass) { ! assertTag(compilerToVM().constantPoolRemapInstructionOperandFromCache(this, methodRefCacheIndex), JVM_CONSTANT.MethodRef); return ResolvedJavaMethod.isSignaturePolymorphic(klass, getNameOf(methodRefCacheIndex), runtime().getHostJVMCIBackend().getMetaAccess()); } @Override public String toString() {
< prev index next >