# HG changeset patch # User twisti # Date 1440801726 36000 # Node ID a0e5714d54360197d6f9bfc9fafb825a1f879b5e # Parent 6292599feb7545263d0286d7140212f158981a56 Remove Java implementation of HotSpotConstantPool Cache and ResolvedReferences and HotSpotSymbol. diff -r 6292599feb75 -r a0e5714d5436 jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/CompilerToVMImpl.java --- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/CompilerToVMImpl.java Fri Aug 28 17:18:18 2015 -0700 +++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/CompilerToVMImpl.java Fri Aug 28 12:42:06 2015 -1000 @@ -25,7 +25,6 @@ import static jdk.internal.jvmci.inittimer.InitTimer.*; import jdk.internal.jvmci.code.*; -import jdk.internal.jvmci.common.*; import jdk.internal.jvmci.inittimer.*; import jdk.internal.jvmci.meta.*; @@ -74,39 +73,19 @@ public native Object resolveConstantInPool(HotSpotConstantPool constantPool, int cpi); - public Object resolvePossiblyCachedConstantInPool(HotSpotConstantPool constantPool, int cpi) { - JVMCIError.guarantee(!HotSpotConstantPool.Options.UseConstantPoolCacheJavaCode.getValue(), ""); - return resolvePossiblyCachedConstantInPool0(constantPool, cpi); - } - - private native Object resolvePossiblyCachedConstantInPool0(HotSpotConstantPool constantPool, int cpi); + public native Object resolvePossiblyCachedConstantInPool(HotSpotConstantPool constantPool, int cpi); @Override public native int lookupNameAndTypeRefIndexInPool(HotSpotConstantPool constantPool, int cpi); @Override - public String lookupNameRefInPool(HotSpotConstantPool constantPool, int cpi) { - JVMCIError.guarantee(!HotSpotConstantPool.Options.UseConstantPoolCacheJavaCode.getValue(), ""); - return lookupNameRefInPool0(constantPool, cpi); - } - - private native String lookupNameRefInPool0(HotSpotConstantPool constantPool, int cpi); + public native String lookupNameRefInPool(HotSpotConstantPool constantPool, int cpi); @Override - public String lookupSignatureRefInPool(HotSpotConstantPool constantPool, int cpi) { - JVMCIError.guarantee(!HotSpotConstantPool.Options.UseConstantPoolCacheJavaCode.getValue(), ""); - return lookupSignatureRefInPool0(constantPool, cpi); - } - - private native String lookupSignatureRefInPool0(HotSpotConstantPool constantPool, int cpi); + public native String lookupSignatureRefInPool(HotSpotConstantPool constantPool, int cpi); @Override - public int lookupKlassRefIndexInPool(HotSpotConstantPool constantPool, int cpi) { - JVMCIError.guarantee(!HotSpotConstantPool.Options.UseConstantPoolCacheJavaCode.getValue(), ""); - return lookupKlassRefIndexInPool0(constantPool, cpi); - } - - private native int lookupKlassRefIndexInPool0(HotSpotConstantPool constantPool, int cpi); + public native int lookupKlassRefIndexInPool(HotSpotConstantPool constantPool, int cpi); public native HotSpotResolvedObjectTypeImpl resolveTypeInPool(HotSpotConstantPool constantPool, int cpi); @@ -119,20 +98,10 @@ @Override public native HotSpotResolvedObjectTypeImpl resolveFieldInPool(HotSpotConstantPool constantPool, int cpi, byte opcode, long[] info); - public int constantPoolRemapInstructionOperandFromCache(HotSpotConstantPool constantPool, int cpi) { - JVMCIError.guarantee(!HotSpotConstantPool.Options.UseConstantPoolCacheJavaCode.getValue(), ""); - return constantPoolRemapInstructionOperandFromCache0(constantPool, cpi); - } - - private native int constantPoolRemapInstructionOperandFromCache0(HotSpotConstantPool constantPool, int cpi); + public native int constantPoolRemapInstructionOperandFromCache(HotSpotConstantPool constantPool, int cpi); @Override - public Object lookupAppendixInPool(HotSpotConstantPool constantPool, int cpi) { - JVMCIError.guarantee(!HotSpotConstantPool.Options.UseConstantPoolCacheJavaCode.getValue(), ""); - return lookupAppendixInPool0(constantPool, cpi); - } - - private native Object lookupAppendixInPool0(HotSpotConstantPool constantPool, int cpi); + public native Object lookupAppendixInPool(HotSpotConstantPool constantPool, int cpi); @Override public native void initializeConfiguration(HotSpotVMConfig config); @@ -209,12 +178,7 @@ public native long getTimeStamp(); - public String getSymbol(long metaspaceSymbol) { - JVMCIError.guarantee(!HotSpotConstantPool.Options.UseConstantPoolCacheJavaCode.getValue(), ""); - return getSymbol0(metaspaceSymbol); - } - - private native String getSymbol0(long metaspaceSymbol); + public native String getSymbol(long metaspaceSymbol); public native void resolveInvokeDynamicInPool(HotSpotConstantPool constantPool, int index); diff -r 6292599feb75 -r a0e5714d5436 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 Aug 28 17:18:18 2015 -0700 +++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotConstantPool.java Fri Aug 28 12:42:06 2015 -1000 @@ -26,24 +26,15 @@ import static jdk.internal.jvmci.hotspot.HotSpotJVMCIRuntime.*; import java.lang.invoke.*; -import java.util.*; import jdk.internal.jvmci.common.*; import jdk.internal.jvmci.meta.*; -import jdk.internal.jvmci.options.*; /** * Implementation of {@link ConstantPool} for HotSpot. */ public final class HotSpotConstantPool implements ConstantPool, HotSpotProxified, MetaspaceWrapperObject { - public static class Options { - // @formatter:off - @Option(help = "Use Java code to access the constant pool cache and resolved references array", type = OptionType.Expert) - public static final OptionValue UseConstantPoolCacheJavaCode = new OptionValue<>(false); - // @formatter:on - } - /** * Subset of JVM bytecode opcodes used by {@link HotSpotConstantPool}. */ @@ -189,227 +180,6 @@ private volatile LookupTypeCacheElement lastLookupType; /** - * The constant pool cache of this constant pool. - */ - private final Cache cache; - - /** - * Represents a {@code ConstantPoolCache}. The cache needs to be lazy since the constant pool - * cache is created when the methods of this class are rewritten and rewriting happens when the - * class is linked. - */ - private final class Cache { - - private long address; - - public Cache() { - // Maybe the constant pool cache already exists... - queryAddress(); - } - - /** - * Queries the current value of {@code ConstantPool::_cache} if the current address is null. - */ - private void queryAddress() { - if (address == 0) { - address = unsafe.getAddress(getMetaspaceConstantPool() + runtime().getConfig().constantPoolCacheOffset); - } - } - - /** - * Returns whether a constant pool cache for this constant pool exists. - * - * @return true if it exists, false otherwise - */ - public boolean exists() { - queryAddress(); - return address != 0; - } - - /** - * Represents a {@code ConstantPoolCacheEntry}. - */ - private final class Entry { - - private final long address; - - public Entry(final long address) { - this.address = address; - } - - /** - * {@code ConstantPoolCacheEntry::_indices} is volatile of type {@code intx}. - * - * @return value of field {@code _indices} - */ - private long getIndices() { - assert runtime().getHostJVMCIBackend().getTarget().wordSize == 8 : "port to non-64-bit platform"; - return unsafe.getLongVolatile(null, address + runtime().getConfig().constantPoolCacheEntryIndicesOffset); - } - - /** - * {@code ConstantPoolCacheEntry::_f1} is volatile of type {@code Metadata*}. - * - * @return value of field {@code _f1} - */ - private long getF1() { - assert runtime().getHostJVMCIBackend().getTarget().wordSize == 8 : "port to non-64-bit platform"; - return unsafe.getLongVolatile(null, address + runtime().getConfig().constantPoolCacheEntryF1Offset); - } - - /** - * {@code ConstantPoolCacheEntry::_f2} is volatile of type {@code intx}. - * - * @return value of field {@code _f2} - */ - private long getF2() { - assert runtime().getHostJVMCIBackend().getTarget().wordSize == 8 : "port to non-64-bit platform"; - return unsafe.getLongVolatile(null, address + runtime().getConfig().constantPoolCacheEntryF2Offset); - } - - /** - * {@code ConstantPoolCacheEntry::_flags} is volatile of type {@code intx}. - * - * @return flag bits - */ - private long flags() { - assert runtime().getHostJVMCIBackend().getTarget().wordSize == 8 : "port to non-64-bit platform"; - return unsafe.getLongVolatile(null, address + runtime().getConfig().constantPoolCacheEntryFlagsOffset); - } - - private boolean isF1Null() { - final long f1 = getF1(); - return f1 == 0; - } - - /** - * Returns the constant pool index for this entry. See - * {@code ConstantPoolCacheEntry::constant_pool_index()} - * - * @return the constant pool index for this entry - */ - public int getConstantPoolIndex() { - return ((int) getIndices()) & runtime().getConfig().constantPoolCacheEntryCpIndexMask; - } - - /** - * See {@code ConstantPoolCache::has_appendix()}. - * - * @return true if there is an appendix, false otherwise - */ - private boolean hasAppendix() { - return (!isF1Null()) && (flags() & (1 << runtime().getConfig().constantPoolCacheEntryHasAppendixShift)) != 0; - } - - /** - * See {@code ConstantPoolCache::appendix_if_resolved()}. - */ - public Object getAppendixIfResolved() { - if (!hasAppendix()) { - return null; - } - final int index = ((int) getF2()) + runtime().getConfig().constantPoolCacheEntryIndyResolvedReferencesAppendixOffset; - return resolvedReferences.getArray()[index]; - } - } - - /** - * Get the constant pool cache entry at index {@code index}. - * - * @param index index of entry to return - * @return constant pool cache entry at given index - */ - public Entry getEntryAt(int index) { - queryAddress(); - assert exists(); - HotSpotVMConfig config = runtime().getConfig(); - return new Entry(address + config.constantPoolCacheSize + config.constantPoolCacheEntrySize * index); - } - - /** - * Maps the constant pool cache index back to a constant pool index. See - * {@code ConstantPool::remap_instruction_operand_from_cache}. - * - * @param index the constant pool cache index - * @return constant pool index - */ - public int constantPoolCacheIndexToConstantPoolIndex(int index) { - final int cacheIndex = index - runtime().getConfig().constantPoolCpCacheIndexTag; - return getEntryAt(cacheIndex).getConstantPoolIndex(); - } - - } - - /** - * Resolved references of this constant pool. - */ - private final ResolvedReferences resolvedReferences = new ResolvedReferences(); - - /** - * Hide the resolved references array in a private class so it cannot be accessed directly. The - * reason is the resolved references array is created when the constant pool cache is created. - * - * @see Cache - */ - private final class ResolvedReferences { - - /** - * Pointer to the {@code ConstantPool::_resolved_references} array. - */ - private Object[] resolvedReferences; - - /** - * Map of constant pool indexes to {@code ConstantPool::_resolved_references} indexes. - */ - private final HashMap referenceMap = new HashMap<>(); - - /** - * Returns the {@code ConstantPool::_resolved_references} array for this constant pool. - * - * @return resolved references array if exists, null otherwise - */ - public Object[] getArray() { - if (resolvedReferences == null) { - final long handle = unsafe.getAddress(getMetaspaceConstantPool() + runtime().getConfig().constantPoolResolvedReferencesOffset); - if (handle != 0) { - resolvedReferences = (Object[]) runtime().getCompilerToVM().readUncompressedOop(handle + runtime().getConfig().handleHandleOffset); - fillReferenceMap(); - } - } - return resolvedReferences; - } - - /** - * Fills the {@link #referenceMap} with all the values from - * {@code ConstantPool::_reference_map} for faster lookup. - */ - private void fillReferenceMap() { - // It is possible there is a resolved references array but no reference map. - final long address = unsafe.getAddress(getMetaspaceConstantPool() + runtime().getConfig().constantPoolReferenceMapOffset); - if (address != 0) { - final int length = unsafe.getInt(null, address + runtime().getConfig().arrayU1LengthOffset); - for (int i = 0; i < length; i++) { - final int value = unsafe.getShort(address + runtime().getConfig().arrayU2DataOffset + i * Short.BYTES); - referenceMap.put(value, i); - } - } - } - - /** - * See {@code ConstantPool::cp_to_object_index}. - * - * @param cpi constant pool index - * @return resolved references array index - */ - public int constantPoolIndexToResolvedReferencesIndex(int cpi) { - final Integer index = referenceMap.get(cpi); - // We might not find the index for jsr292 call. - return (index == null) ? -1 : index; - } - - } - - /** * Gets the JVMCI mirror from a HotSpot constant pool.The VM is responsible for ensuring that * the ConstantPool is kept alive for the duration of this call and the * {@link HotSpotJVMCIMetaAccessContext} keeps it alive after that. @@ -426,9 +196,6 @@ private HotSpotConstantPool(long metaspaceConstantPool) { this.metaspaceConstantPool = metaspaceConstantPool; - - // Cache constructor needs metaspaceConstantPool. - cache = new Cache(); } /** @@ -603,12 +370,7 @@ * @return name as {@link String} */ private String getNameRefAt(int index) { - if (Options.UseConstantPoolCacheJavaCode.getValue()) { - final int nameRefIndex = getNameRefIndexAt(getNameAndTypeRefIndexAt(index)); - return new HotSpotSymbol(getEntryAt(nameRefIndex)).asString(); - } else { - return runtime().getCompilerToVM().lookupNameRefInPool(this, index); - } + return runtime().getCompilerToVM().lookupNameRefInPool(this, index); } /** @@ -632,12 +394,7 @@ * @return signature as {@link String} */ private String getSignatureRefAt(int index) { - if (Options.UseConstantPoolCacheJavaCode.getValue()) { - final int signatureRefIndex = getSignatureRefIndexAt(getNameAndTypeRefIndexAt(index)); - return new HotSpotSymbol(getEntryAt(signatureRefIndex)).asString(); - } else { - return runtime().getCompilerToVM().lookupSignatureRefInPool(this, index); - } + return runtime().getCompilerToVM().lookupSignatureRefInPool(this, index); } /** @@ -654,38 +411,13 @@ } /** - * Gets the klass reference index constant pool entry at index {@code index}. See - * {@code ConstantPool::klass_ref_index_at}. - * - * @param index constant pool index - * @param cached whether to go through the constant pool cache - * @return klass reference index - */ - private int getKlassRefIndexAt(int index, boolean cached) { - int cpi = index; - if (cached && cache.exists()) { - // change byte-ordering and go via cache - cpi = cache.constantPoolCacheIndexToConstantPoolIndex(index); - } - assertTagIsFieldOrMethod(cpi); - final int refIndex = unsafe.getInt(getMetaspaceConstantPool() + runtime().getConfig().constantPoolSize + cpi * runtime().getHostJVMCIBackend().getTarget().wordSize); - // klass ref index is in the low 16-bits. - return refIndex & 0xFFFF; - } - - /** - * Gets the klass reference index constant pool entry at index {@code index}. See - * {@code ConstantPool::klass_ref_index_at}. + * Gets the klass reference index constant pool entry at index {@code index}. * * @param index constant pool index * @return klass reference index */ private int getKlassRefIndexAt(int index) { - if (Options.UseConstantPoolCacheJavaCode.getValue()) { - return getKlassRefIndexAt(index, true); - } else { - return runtime().getCompilerToVM().lookupKlassRefIndexInPool(this, index); - } + return runtime().getCompilerToVM().lookupKlassRefIndexInPool(this, index); } /** @@ -696,14 +428,10 @@ * @return klass reference index */ private int getUncachedKlassRefIndexAt(int index) { - if (Options.UseConstantPoolCacheJavaCode.getValue()) { - return getKlassRefIndexAt(index, false); - } else { - 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. - return refIndex & 0xFFFF; - } + 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. + return refIndex & 0xFFFF; } /** @@ -766,33 +494,7 @@ * "pseudo strings" (arbitrary live objects) patched into a String entry. Such * entries do not have a symbol in the constant pool slot. */ - Object string; - if (Options.UseConstantPoolCacheJavaCode.getValue()) { - // See: ConstantPool::resolve_constant_at_impl - /* - * Note: Call getArray() before constantPoolIndexToResolvedReferencesIndex() - * because it fills the map if the array exists. - */ - Object[] localResolvedReferences = resolvedReferences.getArray(); - final int index = resolvedReferences.constantPoolIndexToResolvedReferencesIndex(cpi); - assert index >= 0; - // See: ConstantPool::string_at_impl - string = localResolvedReferences[index]; - if (string != null) { - assert string instanceof String || getEntryAt(index) == 0L; - return HotSpotObjectConstantImpl.forObject(string); - } else { - final long metaspaceSymbol = getEntryAt(cpi); - if (metaspaceSymbol != 0L) { - HotSpotSymbol symbol = new HotSpotSymbol(metaspaceSymbol); - string = symbol.asString().intern(); - // See: ConstantPool::string_at_put - localResolvedReferences[index] = string; - } - } - } else { - string = runtime().getCompilerToVM().resolvePossiblyCachedConstantInPool(this, cpi); - } + Object string = runtime().getCompilerToVM().resolvePossiblyCachedConstantInPool(this, cpi); return HotSpotObjectConstantImpl.forObject(string); case MethodHandle: case MethodHandleInError: @@ -808,18 +510,7 @@ @Override public String lookupUtf8(int cpi) { assertTag(cpi, JVM_CONSTANT.Utf8); - String s; - if (Options.UseConstantPoolCacheJavaCode.getValue()) { - HotSpotSymbol symbol = new HotSpotSymbol(getEntryAt(cpi)); - s = symbol.asString(); - // It shouldn't but just in case something went wrong... - if (s == null) { - throw JVMCIError.shouldNotReachHere("malformed UTF-8 string in constant pool"); - } - } else { - s = runtime().getCompilerToVM().getSymbol(getEntryAt(cpi)); - } - return s; + return runtime().getCompilerToVM().getSymbol(getEntryAt(cpi)); } @Override @@ -831,21 +522,7 @@ public JavaConstant lookupAppendix(int cpi, int opcode) { assert Bytecodes.isInvoke(opcode); final int index = rawIndexToConstantPoolIndex(cpi, opcode); - - Object appendix = null; - - if (Options.UseConstantPoolCacheJavaCode.getValue()) { - if (!cache.exists()) { - // Nothing to load yet. - return null; - } - final int cacheIndex = decodeConstantPoolCacheIndex(index); - Cache.Entry entry = cache.getEntryAt(cacheIndex); - appendix = entry.getAppendixIfResolved(); - } else { - appendix = runtime().getCompilerToVM().lookupAppendixInPool(this, index); - } - + Object appendix = runtime().getCompilerToVM().lookupAppendixInPool(this, index); if (appendix == null) { return null; } else { @@ -954,17 +631,8 @@ break; case Bytecodes.INVOKEDYNAMIC: { // invokedynamic instructions point to a constant pool cache entry. - if (Options.UseConstantPoolCacheJavaCode.getValue()) { - // index = decodeConstantPoolCacheIndex(cpi) + - // runtime().getConfig().constantPoolCpCacheIndexTag; - // index = cache.constantPoolCacheIndexToConstantPoolIndex(index); - final int cacheIndex = cpi; - index = cache.getEntryAt(decodeInvokedynamicIndex(cacheIndex)).getConstantPoolIndex(); - // JVMCIError.guarantee(index == x, index + " != " + x); - } else { - index = decodeConstantPoolCacheIndex(cpi) + runtime().getConfig().constantPoolCpCacheIndexTag; - index = runtime().getCompilerToVM().constantPoolRemapInstructionOperandFromCache(this, index); - } + index = decodeConstantPoolCacheIndex(cpi) + runtime().getConfig().constantPoolCpCacheIndexTag; + index = runtime().getCompilerToVM().constantPoolRemapInstructionOperandFromCache(this, index); break; } case Bytecodes.GETSTATIC: @@ -976,16 +644,8 @@ case Bytecodes.INVOKESTATIC: case Bytecodes.INVOKEINTERFACE: { // invoke and field instructions point to a constant pool cache entry. - if (Options.UseConstantPoolCacheJavaCode.getValue()) { - // index = rawIndexToConstantPoolIndex(cpi, opcode); - // index = cache.constantPoolCacheIndexToConstantPoolIndex(index); - final int cacheIndex = cpi; - index = cache.getEntryAt(cacheIndex).getConstantPoolIndex(); - // JVMCIError.guarantee(index == x, index + " != " + x); - } else { - index = rawIndexToConstantPoolIndex(cpi, opcode); - index = runtime().getCompilerToVM().constantPoolRemapInstructionOperandFromCache(this, index); - } + index = rawIndexToConstantPoolIndex(cpi, opcode); + index = runtime().getCompilerToVM().constantPoolRemapInstructionOperandFromCache(this, index); break; } default: @@ -1036,13 +696,7 @@ } private boolean isInvokeHandle(int methodRefCacheIndex, HotSpotResolvedObjectTypeImpl klass) { - int index; - if (Options.UseConstantPoolCacheJavaCode.getValue()) { - index = cache.constantPoolCacheIndexToConstantPoolIndex(methodRefCacheIndex); - } else { - index = runtime().getCompilerToVM().constantPoolRemapInstructionOperandFromCache(this, methodRefCacheIndex); - } - assertTag(index, JVM_CONSTANT.MethodRef); + assertTag(runtime().getCompilerToVM().constantPoolRemapInstructionOperandFromCache(this, methodRefCacheIndex), JVM_CONSTANT.MethodRef); return ResolvedJavaMethod.isSignaturePolymorphic(klass, getNameRefAt(methodRefCacheIndex), runtime().getHostJVMCIBackend().getMetaAccess()); } diff -r 6292599feb75 -r a0e5714d5436 jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotSymbol.java --- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotSymbol.java Fri Aug 28 17:18:18 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,153 +0,0 @@ -/* - * Copyright (c) 2013, 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.internal.jvmci.hotspot; - -import static jdk.internal.jvmci.common.UnsafeAccess.*; -import static jdk.internal.jvmci.hotspot.HotSpotJVMCIRuntime.*; - -import java.io.*; -import java.util.*; - -/** - * Represents a metaspace {@code Symbol}. - */ -public class HotSpotSymbol { - - private final long metaspaceSymbol; - - public HotSpotSymbol(long metaspaceSymbol) { - assert metaspaceSymbol != 0; - this.metaspaceSymbol = metaspaceSymbol; - } - - /** - * Decodes this {@code Symbol} and returns the symbol string as {@link java.lang.String}. - * - * @return the decoded string, or null if there was a decoding error - */ - public String asString() { - return readModifiedUTF8(asByteArray()); - } - - /** - * Reads the modified UTF-8 string in {@code buf} and converts it to a {@link String}. The - * implementation is taken from {@link java.io.DataInputStream#readUTF(DataInput)} and adapted - * to operate on a {@code byte} array directly for performance reasons. - * - * @see java.io.DataInputStream#readUTF(DataInput) - */ - private static String readModifiedUTF8(byte[] buf) { - final int utflen = buf.length; - byte[] bytearr = null; - char[] chararr = new char[utflen]; - - int c; - int char2; - int char3; - int count = 0; - int chararrCount = 0; - - bytearr = buf; - - while (count < utflen) { - c = bytearr[count] & 0xff; - if (c > 127) { - break; - } - count++; - chararr[chararrCount++] = (char) c; - } - - while (count < utflen) { - c = bytearr[count] & 0xff; - switch (c >> 4) { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - /* 0xxxxxxx */ - count++; - chararr[chararrCount++] = (char) c; - break; - case 12: - case 13: - /* 110x xxxx 10xx xxxx */ - count += 2; - if (count > utflen) { - // malformed input: partial character at end - return null; - } - char2 = bytearr[count - 1]; - if ((char2 & 0xC0) != 0x80) { - // malformed input around byte - return null; - } - chararr[chararrCount++] = (char) (((c & 0x1F) << 6) | (char2 & 0x3F)); - break; - case 14: - /* 1110 xxxx 10xx xxxx 10xx xxxx */ - count += 3; - if (count > utflen) { - // malformed input: partial character at end - return null; - } - char2 = bytearr[count - 2]; - char3 = bytearr[count - 1]; - if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80)) { - // malformed input around byte - return null; - } - chararr[chararrCount++] = (char) (((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0)); - break; - default: - /* 10xx xxxx, 1111 xxxx */ - // malformed input around byte - return null; - } - } - // The number of chars produced may be less than utflen - char[] value = Arrays.copyOf(chararr, chararrCount); - return new String(value); - } - - private byte[] asByteArray() { - final int length = getLength(); - byte[] result = new byte[length]; - for (int index = 0; index < length; index++) { - result[index] = getByteAt(index); - } - return result; - } - - private int getLength() { - return unsafe.getShort(metaspaceSymbol + runtime().getConfig().symbolLengthOffset); - } - - private byte getByteAt(int index) { - return unsafe.getByte(metaspaceSymbol + runtime().getConfig().symbolBodyOffset + index); - } -} diff -r 6292599feb75 -r a0e5714d5436 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 Aug 28 17:18:18 2015 -0700 +++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotVMConfig.java Fri Aug 28 12:42:06 2015 -1000 @@ -810,8 +810,6 @@ @HotSpotVMField(name = "oopDesc::_mark", type = "markOop", get = HotSpotVMField.Type.OFFSET) @Stable public int markOffset; @HotSpotVMField(name = "oopDesc::_metadata._klass", type = "Klass*", get = HotSpotVMField.Type.OFFSET) @Stable public int hubOffset; - @HotSpotVMField(name = "Handle::_handle", type = "oop*", get = HotSpotVMField.Type.OFFSET) @Stable public int handleHandleOffset; - @HotSpotVMField(name = "Klass::_prototype_header", type = "markOop", get = HotSpotVMField.Type.OFFSET) @Stable public int prototypeMarkWordOffset; @HotSpotVMField(name = "Klass::_subklass", type = "Klass*", get = HotSpotVMField.Type.OFFSET) @Stable public int subklassOffset; @HotSpotVMField(name = "Klass::_next_sibling", type = "Klass*", get = HotSpotVMField.Type.OFFSET) @Stable public int nextSiblingOffset; @@ -1086,29 +1084,11 @@ @HotSpotVMType(name = "ConstantPool", get = HotSpotVMType.Type.SIZE) @Stable public int constantPoolSize; @HotSpotVMField(name = "ConstantPool::_tags", type = "Array*", get = HotSpotVMField.Type.OFFSET) @Stable public int constantPoolTagsOffset; - @HotSpotVMField(name = "ConstantPool::_cache", type = "ConstantPoolCache*", get = HotSpotVMField.Type.OFFSET) @Stable public int constantPoolCacheOffset; @HotSpotVMField(name = "ConstantPool::_pool_holder", type = "InstanceKlass*", get = HotSpotVMField.Type.OFFSET) @Stable public int constantPoolHolderOffset; @HotSpotVMField(name = "ConstantPool::_length", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int constantPoolLengthOffset; - @HotSpotVMField(name = "ConstantPool::_resolved_references", type = "jobject", get = HotSpotVMField.Type.OFFSET) @Stable public int constantPoolResolvedReferencesOffset; - @HotSpotVMField(name = "ConstantPool::_reference_map", type = "Array*", get = HotSpotVMField.Type.OFFSET) @Stable public int constantPoolReferenceMapOffset; @HotSpotVMConstant(name = "ConstantPool::CPCACHE_INDEX_TAG") @Stable public int constantPoolCpCacheIndexTag; - @HotSpotVMType(name = "ConstantPoolCache", get = HotSpotVMType.Type.SIZE) @Stable public int constantPoolCacheSize; - @HotSpotVMField(name = "ConstantPoolCache::_length", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int constantPoolCacheLengthOffset; - - @HotSpotVMType(name = "ConstantPoolCacheEntry", get = HotSpotVMType.Type.SIZE) @Stable public int constantPoolCacheEntrySize; - @HotSpotVMField(name = "ConstantPoolCacheEntry::_indices", type = "intx", get = HotSpotVMField.Type.OFFSET) @Stable public int constantPoolCacheEntryIndicesOffset; - @HotSpotVMField(name = "ConstantPoolCacheEntry::_f1", type = "volatile Metadata*", get = HotSpotVMField.Type.OFFSET) @Stable public int constantPoolCacheEntryF1Offset; - @HotSpotVMField(name = "ConstantPoolCacheEntry::_f2", type = "intx", get = HotSpotVMField.Type.OFFSET) @Stable public int constantPoolCacheEntryF2Offset; - @HotSpotVMField(name = "ConstantPoolCacheEntry::_flags", type = "intx", get = HotSpotVMField.Type.OFFSET) @Stable public int constantPoolCacheEntryFlagsOffset; - - @HotSpotVMConstant(name = "ConstantPoolCacheEntry::has_appendix_shift") @Stable public int constantPoolCacheEntryHasAppendixShift; - - @HotSpotVMConstant(name = "ConstantPoolCacheEntry::cp_index_mask") @Stable public int constantPoolCacheEntryCpIndexMask; - - @HotSpotVMConstant(name = "ConstantPoolCacheEntry::_indy_resolved_references_appendix_offset") @Stable public int constantPoolCacheEntryIndyResolvedReferencesAppendixOffset; - @HotSpotVMConstant(name = "JVM_CONSTANT_Utf8") @Stable public int jvmConstantUtf8; @HotSpotVMConstant(name = "JVM_CONSTANT_Integer") @Stable public int jvmConstantInteger; @HotSpotVMConstant(name = "JVM_CONSTANT_Long") @Stable public int jvmConstantLong; diff -r 6292599feb75 -r a0e5714d5436 jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotVmSymbols.java --- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotVmSymbols.java Fri Aug 28 17:18:18 2015 -0700 +++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotVmSymbols.java Fri Aug 28 12:42:06 2015 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -24,8 +24,6 @@ import static jdk.internal.jvmci.common.UnsafeAccess.*; import static jdk.internal.jvmci.hotspot.HotSpotJVMCIRuntime.*; - -import jdk.internal.jvmci.common.*; import sun.misc.*; /** @@ -45,17 +43,6 @@ HotSpotVMConfig config = runtime.getConfig(); assert config.vmSymbolsFirstSID <= index && index < config.vmSymbolsSIDLimit : "index " + index + " is out of bounds"; assert config.symbolPointerSize == Unsafe.ADDRESS_SIZE : "the following address read is broken"; - final long metaspaceSymbol = unsafe.getAddress(config.vmSymbolsSymbols + index * config.symbolPointerSize); - if (HotSpotConstantPool.Options.UseConstantPoolCacheJavaCode.getValue()) { - HotSpotSymbol symbol = new HotSpotSymbol(metaspaceSymbol); - String s = symbol.asString(); - // It shouldn't but just in case something went wrong... - if (s == null) { - throw JVMCIError.shouldNotReachHere("malformed UTF-8 string in constant pool"); - } - return s; - } else { - return runtime.getCompilerToVM().getSymbol(metaspaceSymbol); - } + return runtime.getCompilerToVM().getSymbol(unsafe.getAddress(config.vmSymbolsSymbols + index * config.symbolPointerSize)); } } diff -r 6292599feb75 -r a0e5714d5436 src/share/vm/jvmci/jvmciCompilerToVM.cpp --- a/src/share/vm/jvmci/jvmciCompilerToVM.cpp Fri Aug 28 17:18:18 2015 -0700 +++ b/src/share/vm/jvmci/jvmciCompilerToVM.cpp Fri Aug 28 12:42:06 2015 -1000 @@ -1151,16 +1151,16 @@ {CC"canInlineMethod", CC"("HS_RESOLVED_METHOD")Z", FN_PTR(canInlineMethod)}, {CC"shouldInlineMethod", CC"("HS_RESOLVED_METHOD")Z", FN_PTR(shouldInlineMethod)}, {CC"lookupType", CC"("STRING CLASS"Z)"HS_RESOLVED_KLASS, FN_PTR(lookupType)}, - {CC"lookupNameRefInPool0", CC"("HS_CONSTANT_POOL"I)"STRING, FN_PTR(lookupNameRefInPool)}, + {CC"lookupNameRefInPool", CC"("HS_CONSTANT_POOL"I)"STRING, FN_PTR(lookupNameRefInPool)}, {CC"lookupNameAndTypeRefIndexInPool", CC"("HS_CONSTANT_POOL"I)I", FN_PTR(lookupNameAndTypeRefIndexInPool)}, - {CC"lookupSignatureRefInPool0", CC"("HS_CONSTANT_POOL"I)"STRING, FN_PTR(lookupSignatureRefInPool)}, - {CC"lookupKlassRefIndexInPool0", CC"("HS_CONSTANT_POOL"I)I", FN_PTR(lookupKlassRefIndexInPool)}, + {CC"lookupSignatureRefInPool", CC"("HS_CONSTANT_POOL"I)"STRING, FN_PTR(lookupSignatureRefInPool)}, + {CC"lookupKlassRefIndexInPool", CC"("HS_CONSTANT_POOL"I)I", FN_PTR(lookupKlassRefIndexInPool)}, {CC"lookupKlassInPool", CC"("HS_CONSTANT_POOL"I)Ljava/lang/Object;", FN_PTR(lookupKlassInPool)}, - {CC"lookupAppendixInPool0", CC"("HS_CONSTANT_POOL"I)"OBJECT, FN_PTR(lookupAppendixInPool)}, + {CC"lookupAppendixInPool", CC"("HS_CONSTANT_POOL"I)"OBJECT, FN_PTR(lookupAppendixInPool)}, {CC"lookupMethodInPool", CC"("HS_CONSTANT_POOL"IB)"HS_RESOLVED_METHOD, FN_PTR(lookupMethodInPool)}, - {CC"constantPoolRemapInstructionOperandFromCache0",CC"("HS_CONSTANT_POOL"I)I", FN_PTR(constantPoolRemapInstructionOperandFromCache)}, + {CC"constantPoolRemapInstructionOperandFromCache", CC"("HS_CONSTANT_POOL"I)I", FN_PTR(constantPoolRemapInstructionOperandFromCache)}, {CC"resolveConstantInPool", CC"("HS_CONSTANT_POOL"I)"OBJECT, FN_PTR(resolveConstantInPool)}, - {CC"resolvePossiblyCachedConstantInPool0", CC"("HS_CONSTANT_POOL"I)"OBJECT, FN_PTR(resolvePossiblyCachedConstantInPool)}, + {CC"resolvePossiblyCachedConstantInPool", CC"("HS_CONSTANT_POOL"I)"OBJECT, FN_PTR(resolvePossiblyCachedConstantInPool)}, {CC"resolveTypeInPool", CC"("HS_CONSTANT_POOL"I)"HS_RESOLVED_KLASS, FN_PTR(resolveTypeInPool)}, {CC"resolveFieldInPool", CC"("HS_CONSTANT_POOL"IB[J)"HS_RESOLVED_KLASS, FN_PTR(resolveFieldInPool)}, {CC"resolveInvokeDynamicInPool", CC"("HS_CONSTANT_POOL"I)V", FN_PTR(resolveInvokeDynamicInPool)}, @@ -1190,7 +1190,7 @@ {CC"allocateCompileId", CC"("HS_RESOLVED_METHOD"I)I", FN_PTR(allocateCompileId)}, {CC"isMature", CC"("METASPACE_METHOD_DATA")Z", FN_PTR(isMature)}, {CC"hasCompiledCodeForOSR", CC"("HS_RESOLVED_METHOD"II)Z", FN_PTR(hasCompiledCodeForOSR)}, - {CC"getSymbol0", CC"(J)"STRING, FN_PTR(getSymbol)}, + {CC"getSymbol", CC"(J)"STRING, FN_PTR(getSymbol)}, {CC"getTimeStamp", CC"()J", FN_PTR(getTimeStamp)}, {CC"getNextStackFrame", CC"("HS_STACK_FRAME_REF "["HS_RESOLVED_METHOD"I)"HS_STACK_FRAME_REF, FN_PTR(getNextStackFrame)}, {CC"materializeVirtualObjects", CC"("HS_STACK_FRAME_REF"Z)V", FN_PTR(materializeVirtualObjects)}, diff -r 6292599feb75 -r a0e5714d5436 src/share/vm/runtime/handles.hpp --- a/src/share/vm/runtime/handles.hpp Fri Aug 28 17:18:18 2015 -0700 +++ b/src/share/vm/runtime/handles.hpp Fri Aug 28 12:42:06 2015 -1000 @@ -62,7 +62,6 @@ // used operators for ease of use. class Handle VALUE_OBJ_CLASS_SPEC { - friend class VMStructs; private: oop* _handle; diff -r 6292599feb75 -r a0e5714d5436 src/share/vm/runtime/vmStructs.cpp --- a/src/share/vm/runtime/vmStructs.cpp Fri Aug 28 17:18:18 2015 -0700 +++ b/src/share/vm/runtime/vmStructs.cpp Fri Aug 28 12:42:06 2015 -1000 @@ -1010,9 +1010,6 @@ /*********************************/ \ /* JNIHandles and JNIHandleBlock */ \ /*********************************/ \ - \ - nonstatic_field(Handle, _handle, oop*) \ - \ static_field(JNIHandles, _global_handles, JNIHandleBlock*) \ static_field(JNIHandles, _weak_global_handles, JNIHandleBlock*) \ static_field(JNIHandles, _deleted_handle, oop) \ @@ -1745,8 +1742,6 @@ /* JNIHandles and JNIHandleBlock */ \ /*********************************/ \ \ - declare_toplevel_type(Handle) \ - \ declare_toplevel_type(JNIHandles) \ declare_toplevel_type(JNIHandleBlock) \ declare_toplevel_type(jobject) \ @@ -2543,22 +2538,9 @@ declare_constant(ConstantPoolCacheEntry::is_final_shift) \ declare_constant(ConstantPoolCacheEntry::is_forced_virtual_shift) \ declare_constant(ConstantPoolCacheEntry::is_vfinal_shift) \ - declare_constant(ConstantPoolCacheEntry::has_appendix_shift) \ - declare_constant(ConstantPoolCacheEntry::has_method_type_shift) \ declare_constant(ConstantPoolCacheEntry::is_field_entry_shift) \ declare_constant(ConstantPoolCacheEntry::tos_state_shift) \ \ - declare_constant(ConstantPoolCacheEntry::cp_index_bits) \ - declare_constant(ConstantPoolCacheEntry::cp_index_mask) \ - declare_constant(ConstantPoolCacheEntry::bytecode_1_shift) \ - declare_constant(ConstantPoolCacheEntry::bytecode_1_mask) \ - declare_constant(ConstantPoolCacheEntry::bytecode_2_shift) \ - declare_constant(ConstantPoolCacheEntry::bytecode_2_mask) \ - \ - declare_constant(ConstantPoolCacheEntry::_indy_resolved_references_appendix_offset) \ - declare_constant(ConstantPoolCacheEntry::_indy_resolved_references_method_type_offset) \ - declare_constant(ConstantPoolCacheEntry::_indy_resolved_references_entries) \ - \ /***************************************/ \ /* java_lang_Thread::ThreadStatus enum */ \ /***************************************/ \