changeset 14100:8c376c174030

Merge with dd783f0ecf171f786674bb5b6b762581c3367f80
author Michael Van De Vanter <michael.van.de.vanter@oracle.com>
date Thu, 06 Mar 2014 16:24:47 -0800
parents 34efe38ee8d8 (current diff) dd783f0ecf17 (diff)
children 2ec05c3f773b
files
diffstat 13 files changed, 410 insertions(+), 250 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Thu Mar 06 15:56:05 2014 -0800
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Thu Mar 06 16:24:47 2014 -0800
@@ -1396,6 +1396,9 @@
     @HotSpotVMConstant(name = "GraalEnv::cache_full") @Stable public int codeInstallResultCacheFull;
     @HotSpotVMConstant(name = "GraalEnv::code_too_large") @Stable public int codeInstallResultCodeTooLarge;
 
+    @HotSpotVMConstant(name = "CompilerToVM::KLASS_TAG") @Stable public int compilerToVMKlassTag;
+    @HotSpotVMConstant(name = "CompilerToVM::SYMBOL_TAG") @Stable public int compilerToVMSymbolTag;
+
     public boolean check() {
         for (Field f : getClass().getDeclaredFields()) {
             int modifiers = f.getModifiers();
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java	Thu Mar 06 15:56:05 2014 -0800
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java	Thu Mar 06 16:24:47 2014 -0800
@@ -116,56 +116,52 @@
      */
     long lookupType(String name, Class<?> accessingClass, boolean eagerResolve);
 
+    long lookupKlassByName(String name, Class<?> accessingClass);
+
     Object lookupConstantInPool(long metaspaceConstantPool, int cpi);
 
-    /**
-     * Looks up a method entry in a constant pool. If the method is resolved, then
-     * {@code unresolvedInfo} is unmodified. Otherwise, it contains these values:
-     * 
-     * <pre>
-     *     [(Symbol*) name,
-     *      (Symbol*) signature,
-     *      (Symbol*) holderName, // only non-zero if holder == 0
-     *      (Klass*)  holder]
-     * </pre>
-     * 
-     * @param metaspaceConstantPool
-     * @param unresolvedInfo an array in which the details for an unresolved method are returned
-     * @return a metaspace Method for a resolved method entry otherwise 0 in which case the values
-     *         returned in {@code unresolvedInfo} should be consulted
-     */
-    long lookupMethodInPool(long metaspaceConstantPool, int cpi, byte opcode, long[] unresolvedInfo);
+    int lookupNameAndTypeRefIndexInPool(long metaspaceConstantPool, int cpi);
+
+    long lookupNameRefInPool(long metaspaceConstantPool, int cpi);
+
+    long lookupSignatureRefInPool(long metaspaceConstantPool, int cpi);
+
+    int lookupKlassRefIndexInPool(long metaspaceConstantPool, int cpi);
 
     /**
      * Looks up a class entry in a constant pool.
      * 
-     * @param metaspaceConstantPool
-     * @param unresolvedTypeName a 1 element array in which the name of the class is returned if
-     *            this method returns 0
-     * @return a metaspace Klass for a resolved method entry otherwise 0 in which case the value
-     *         returned in {@code unresolvedTypeName} should be consulted
+     * @param metaspaceConstantPool metaspace constant pool pointer
+     * @param cpi constant pool index
+     * @return a metaspace Klass for a resolved method entry, a metaspace Symbol otherwise (with
+     *         tagging)
      */
-    long lookupTypeInPool(long metaspaceConstantPool, int cpi, long[] unresolvedTypeName);
+    long lookupKlassInPool(long metaspaceConstantPool, int cpi);
+
+    /**
+     * Looks up a method entry in a constant pool.
+     * 
+     * @param metaspaceConstantPool metaspace constant pool pointer
+     * @param cpi constant pool index
+     * @return a metaspace Method for a resolved method entry, 0 otherwise
+     */
+    long lookupMethodInPool(long metaspaceConstantPool, int cpi, byte opcode);
 
     /**
      * Looks up a field entry in a constant pool and attempts to resolve it. The values returned in
      * {@code info} are:
      * 
      * <pre>
-     *     [(Symbol*) name,
-     *      (Symbol*) typeName,   // only non-zero if type == 0
-     *      (Klass*)  type,
-     *      (Symbol*) holderName, // only non-zero if holder == 0
-     *      (Klass*)  holder,
-     *      (int)     flags,      // only valid if field is resolved
-     *      (int)     offset]     // only valid if field is resolved
+     *     [(int) flags,   // only valid if field is resolved
+     *      (int) offset]  // only valid if field is resolved
      * </pre>
      * 
-     * @param metaspaceConstantPool
+     * @param metaspaceConstantPool metaspace constant pool pointer
+     * @param cpi constant pool index
      * @param info an array in which the details of the field are returned
      * @return true if the field is resolved
      */
-    boolean lookupFieldInPool(long metaspaceConstantPool, int cpi, byte opcode, long[] info);
+    long resolveField(long metaspaceConstantPool, int cpi, byte opcode, long[] info);
 
     void loadReferencedTypeInPool(long metaspaceConstantPool, int cpi, byte opcode);
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java	Thu Mar 06 15:56:05 2014 -0800
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java	Thu Mar 06 16:24:47 2014 -0800
@@ -61,16 +61,31 @@
     public native long lookupType(String name, Class<?> accessingClass, boolean eagerResolve);
 
     @Override
+    public native long lookupKlassByName(String name, Class<?> accessingClass);
+
+    @Override
     public native Object lookupConstantInPool(long metaspaceConstantPool, int cpi);
 
     @Override
-    public native long lookupMethodInPool(long metaspaceConstantPool, int cpi, byte opcode, long[] unresolvedInfo);
+    public native int lookupNameAndTypeRefIndexInPool(long metaspaceConstantPool, int cpi);
+
+    @Override
+    public native long lookupNameRefInPool(long metaspaceConstantPool, int cpi);
+
+    @Override
+    public native long lookupSignatureRefInPool(long metaspaceConstantPool, int cpi);
 
     @Override
-    public native long lookupTypeInPool(long metaspaceConstantPool, int cpi, long[] unresolvedTypeName);
+    public native int lookupKlassRefIndexInPool(long metaspaceConstantPool, int cpi);
 
     @Override
-    public native boolean lookupFieldInPool(long metaspaceConstantPool, int cpi, byte opcode, long[] info);
+    public native long lookupKlassInPool(long metaspaceConstantPool, int cpi);
+
+    @Override
+    public native long lookupMethodInPool(long metaspaceConstantPool, int cpi, byte opcode);
+
+    @Override
+    public native long resolveField(long metaspaceConstantPool, int cpi, byte opcode, long[] info);
 
     @Override
     public native void loadReferencedTypeInPool(long metaspaceConstantPool, int cpi, byte opcode);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstantPool.java	Thu Mar 06 15:56:05 2014 -0800
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstantPool.java	Thu Mar 06 16:24:47 2014 -0800
@@ -25,6 +25,8 @@
 import static com.oracle.graal.graph.UnsafeAccess.*;
 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
 
+import java.lang.invoke.*;
+
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.bytecode.*;
 import com.oracle.graal.graph.*;
@@ -47,6 +49,16 @@
     }
 
     /**
+     * Gets the holder for this constant pool as {@link HotSpotResolvedObjectType}.
+     * 
+     * @return holder for this constant pool
+     */
+    private HotSpotResolvedJavaType getHolder() {
+        final long metaspaceKlass = unsafe.getAddress(metaspaceConstantPool + runtime().getConfig().constantPoolHolderOffset);
+        return (HotSpotResolvedObjectType) HotSpotResolvedObjectType.fromMetaspaceKlass(metaspaceKlass);
+    }
+
+    /**
      * Converts a raw index from the bytecodes to a constant pool index by adding a
      * {@link HotSpotVMConfig#constantPoolCpCacheIndexTag constant}.
      * 
@@ -69,10 +81,10 @@
     }
 
     /**
-     * Returns the constant pool tag at index {@code index}.
+     * Gets the constant pool tag at index {@code index}.
      * 
      * @param index constant pool index
-     * @return constant pool tag at index
+     * @return constant pool tag
      */
     private int getTagAt(int index) {
         assertBounds(index);
@@ -82,10 +94,10 @@
     }
 
     /**
-     * Returns the constant pool entry at index {@code index}.
+     * Gets the constant pool entry at index {@code index}.
      * 
      * @param index constant pool index
-     * @return constant pool entry at index
+     * @return constant pool entry
      */
     private long getEntryAt(int index) {
         assertBounds(index);
@@ -94,7 +106,7 @@
     }
 
     /**
-     * Returns the integer constant pool entry at index {@code index}.
+     * Gets the integer constant pool entry at index {@code index}.
      * 
      * @param index constant pool index
      * @return integer constant pool entry at index
@@ -106,10 +118,10 @@
     }
 
     /**
-     * Returns the long constant pool entry at index {@code index}.
+     * Gets the long constant pool entry at index {@code index}.
      * 
      * @param index constant pool index
-     * @return long constant pool entry at index
+     * @return long constant pool entry
      */
     private long getLongAt(int index) {
         HotSpotVMConfig config = runtime().getConfig();
@@ -118,10 +130,10 @@
     }
 
     /**
-     * Returns the float constant pool entry at index {@code index}.
+     * Gets the float constant pool entry at index {@code index}.
      * 
      * @param index constant pool index
-     * @return float constant pool entry at index
+     * @return float constant pool entry
      */
     private float getFloatAt(int index) {
         HotSpotVMConfig config = runtime().getConfig();
@@ -130,10 +142,10 @@
     }
 
     /**
-     * Returns the double constant pool entry at index {@code index}.
+     * Gets the double constant pool entry at index {@code index}.
      * 
      * @param index constant pool index
-     * @return float constant pool entry at index
+     * @return float constant pool entry
      */
     private double getDoubleAt(int index) {
         HotSpotVMConfig config = runtime().getConfig();
@@ -142,6 +154,91 @@
     }
 
     /**
+     * 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) {
+        HotSpotVMConfig config = runtime().getConfig();
+        assertTag(index, config.jvmConstantNameAndType);
+        return unsafe.getInt(metaspaceConstantPool + config.constantPoolSize + index * runtime().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(metaspaceConstantPool, index);
+    }
+
+    /**
+     * Gets the name of a {@code JVM_CONSTANT_NameAndType} constant pool entry at index
+     * {@code index}.
+     * 
+     * @param index constant pool index
+     * @return name as {@link String}
+     */
+    private String getNameRefAt(int index) {
+        final long name = runtime().getCompilerToVM().lookupNameRefInPool(metaspaceConstantPool, index);
+        HotSpotSymbol symbol = new HotSpotSymbol(name);
+        return symbol.asString();
+    }
+
+    /**
+     * Gets the name reference index of a {@code JVM_CONSTANT_NameAndType} constant pool entry at
+     * index {@code index}.
+     * 
+     * @param index constant pool index
+     * @return name reference index
+     */
+    private int getNameRefIndexAt(int index) {
+        final int refIndex = getNameAndTypeAt(index);
+        // name ref index is in the low 16-bits.
+        return refIndex & 0xFFFF;
+    }
+
+    /**
+     * Gets the signature of a {@code JVM_CONSTANT_NameAndType} constant pool entry at index
+     * {@code index}.
+     * 
+     * @param index constant pool index
+     * @return signature as {@link String}
+     */
+    private String getSignatureRefAt(int index) {
+        final long name = runtime().getCompilerToVM().lookupSignatureRefInPool(metaspaceConstantPool, index);
+        HotSpotSymbol symbol = new HotSpotSymbol(name);
+        return symbol.asString();
+    }
+
+    /**
+     * Gets the signature reference index of a {@code JVM_CONSTANT_NameAndType} constant pool entry
+     * at index {@code index}.
+     * 
+     * @param index constant pool index
+     * @return signature reference index
+     */
+    private int getSignatureRefIndexAt(int index) {
+        final int refIndex = getNameAndTypeAt(index);
+        // signature ref index is in the high 16-bits.
+        return refIndex >>> 16;
+    }
+
+    /**
+     * 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) {
+        return runtime().getCompilerToVM().lookupKlassRefIndexInPool(metaspaceConstantPool, index);
+    }
+
+    /**
      * Asserts that the constant pool index {@code index} is in the bounds of the constant pool.
      * 
      * @param index constant pool index
@@ -281,63 +378,92 @@
     }
 
     /**
-     * Gets a {@link JavaType} corresponding a given metaspace Klass or to a given name if the
-     * former is null.
+     * Gets a {@link JavaType} corresponding a given metaspace Klass or a metaspace Symbol depending
+     * on the {@link HotSpotVMConfig#compilerToVMKlassTag tag}.
      * 
-     * @param metaspaceSymbol a type name
-     * @param metaspaceKlass a resolved type (if non-zero)
-     * @param mayBePrimitive specifies if the requested type may be primitive
+     * @param metaspacePointer either a metaspace Klass or a metaspace Symbol
      */
-    private static JavaType getType(long metaspaceSymbol, long metaspaceKlass, boolean mayBePrimitive) {
-        if (metaspaceKlass == 0L) {
+    private static JavaType getJavaType(final long metaspacePointer) {
+        HotSpotVMConfig config = runtime().getConfig();
+        if ((metaspacePointer & config.compilerToVMSymbolTag) != 0) {
+            final long metaspaceSymbol = metaspacePointer & ~config.compilerToVMSymbolTag;
             String name = new HotSpotSymbol(metaspaceSymbol).asString();
-            if (mayBePrimitive && name.length() == 1) {
-                Kind kind = Kind.fromPrimitiveOrVoidTypeChar(name.charAt(0));
-                return HotSpotResolvedPrimitiveType.fromClass(kind.toJavaClass());
-            }
             return HotSpotUnresolvedJavaType.create(name);
         } else {
-            return HotSpotResolvedObjectType.fromMetaspaceKlass(metaspaceKlass);
+            assert (metaspacePointer & config.compilerToVMKlassTag) == 0;
+            return HotSpotResolvedObjectType.fromMetaspaceKlass(metaspacePointer);
         }
     }
 
     @Override
     public JavaMethod lookupMethod(int cpi, int opcode) {
         final int index = toConstantPoolIndex(cpi, opcode);
-        // {name, signature, unresolved_holder_name, resolved_holder}
-        long[] unresolvedInfo = new long[4];
-        long metaspaceMethod = runtime().getCompilerToVM().lookupMethodInPool(metaspaceConstantPool, index, (byte) opcode, unresolvedInfo);
+        final long metaspaceMethod = runtime().getCompilerToVM().lookupMethodInPool(metaspaceConstantPool, index, (byte) opcode);
         if (metaspaceMethod != 0L) {
             return HotSpotResolvedJavaMethod.fromMetaspace(metaspaceMethod);
         } else {
-            String name = new HotSpotSymbol(unresolvedInfo[0]).asString();
-            String signature = new HotSpotSymbol(unresolvedInfo[1]).asString();
-            JavaType holder = getType(unresolvedInfo[2], unresolvedInfo[3], false);
-            return new HotSpotMethodUnresolved(name, signature, holder);
+            // Get the method's name and signature.
+            String name = getNameRefAt(index);
+            String signature = getSignatureRefAt(index);
+            if (opcode == Bytecodes.INVOKEDYNAMIC) {
+                JavaType holder = HotSpotResolvedJavaType.fromClass(MethodHandle.class);
+                return new HotSpotMethodUnresolved(name, signature, holder);
+            } else {
+                final int klassIndex = getKlassRefIndexAt(index);
+                final long metaspacePointer = runtime().getCompilerToVM().lookupKlassInPool(metaspaceConstantPool, klassIndex);
+                JavaType holder = getJavaType(metaspacePointer);
+                return new HotSpotMethodUnresolved(name, signature, holder);
+            }
         }
     }
 
     @Override
     public JavaType lookupType(int cpi, int opcode) {
-        long[] unresolvedTypeName = {0};
-        long metaspaceKlass = runtime().getCompilerToVM().lookupTypeInPool(metaspaceConstantPool, cpi, unresolvedTypeName);
-        return getType(unresolvedTypeName[0], metaspaceKlass, false);
+        final long metaspacePointer = runtime().getCompilerToVM().lookupKlassInPool(metaspaceConstantPool, cpi);
+        return getJavaType(metaspacePointer);
     }
 
     @Override
     public JavaField lookupField(int cpi, int opcode) {
         final int index = toConstantPoolIndex(cpi, opcode);
-        long[] info = new long[7];
-        boolean resolved = runtime().getCompilerToVM().lookupFieldInPool(metaspaceConstantPool, index, (byte) opcode, info);
-        String name = new HotSpotSymbol(info[0]).asString();
-        JavaType type = getType(info[1], info[2], true);
-        JavaType holder = getType(info[3], info[4], false);
-        int flags = (int) info[5];
-        int offset = (int) info[6];
-        if (resolved) {
-            HotSpotResolvedObjectType resolvedHolder = (HotSpotResolvedObjectType) holder;
-            HotSpotResolvedJavaField f = resolvedHolder.createField(name, type, offset, flags);
-            return f;
+        final int nameAndTypeIndex = getNameAndTypeRefIndexAt(index);
+        final int nameIndex = getNameRefIndexAt(nameAndTypeIndex);
+        String name = lookupUtf8(nameIndex);
+        final int typeIndex = getSignatureRefIndexAt(nameAndTypeIndex);
+        String typeName = lookupUtf8(typeIndex);
+
+        Kind kind = Kind.fromTypeString(typeName);
+        JavaType type;
+        if (kind.isPrimitive()) {
+            type = HotSpotResolvedPrimitiveType.fromKind(kind);
+        } else {
+            final long metaspaceKlass = runtime().getCompilerToVM().lookupKlassByName(typeName, getHolder().mirror());
+            if (metaspaceKlass == 0L) {
+                type = HotSpotUnresolvedJavaType.create(typeName);
+            } else {
+                type = HotSpotResolvedObjectType.fromMetaspaceKlass(metaspaceKlass);
+            }
+        }
+
+        final int holderIndex = getKlassRefIndexAt(index);
+        JavaType holder = lookupType(holderIndex, opcode);
+
+        if (holder instanceof HotSpotResolvedObjectType) {
+            long[] info = new long[2];
+            long metaspaceKlass;
+            try {
+                metaspaceKlass = runtime().getCompilerToVM().resolveField(metaspaceConstantPool, index, (byte) opcode, info);
+            } catch (Throwable t) {
+                /*
+                 * If there was an exception resolving the field we give up and return an unresolved
+                 * field.
+                 */
+                return new HotSpotUnresolvedField(holder, name, type);
+            }
+            HotSpotResolvedObjectType resolvedHolder = (HotSpotResolvedObjectType) HotSpotResolvedObjectType.fromMetaspaceKlass(metaspaceKlass);
+            final int flags = (int) info[0];
+            final long offset = info[1];
+            return resolvedHolder.createField(name, type, offset, flags);
         } else {
             return new HotSpotUnresolvedField(holder, name, type);
         }
@@ -346,11 +472,19 @@
     @Override
     public void loadReferencedType(int cpi, int opcode) {
         int index;
-        if (opcode != Bytecodes.CHECKCAST && opcode != Bytecodes.INSTANCEOF && opcode != Bytecodes.NEW && opcode != Bytecodes.ANEWARRAY && opcode != Bytecodes.MULTIANEWARRAY &&
-                        opcode != Bytecodes.LDC && opcode != Bytecodes.LDC_W && opcode != Bytecodes.LDC2_W) {
-            index = toConstantPoolIndex(cpi, opcode);
-        } else {
-            index = cpi;
+        switch (opcode) {
+            case Bytecodes.CHECKCAST:
+            case Bytecodes.INSTANCEOF:
+            case Bytecodes.NEW:
+            case Bytecodes.ANEWARRAY:
+            case Bytecodes.MULTIANEWARRAY:
+            case Bytecodes.LDC:
+            case Bytecodes.LDC_W:
+            case Bytecodes.LDC2_W:
+                index = cpi;
+                break;
+            default:
+                index = toConstantPoolIndex(cpi, opcode);
         }
         runtime().getCompilerToVM().loadReferencedTypeInPool(metaspaceConstantPool, index, (byte) opcode);
     }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodUnresolved.java	Thu Mar 06 15:56:05 2014 -0800
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodUnresolved.java	Thu Mar 06 16:24:47 2014 -0800
@@ -48,4 +48,21 @@
     public JavaType getDeclaringClass() {
         return holder;
     }
+
+    @Override
+    public int hashCode() {
+        return super.hashCode();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null || !(obj instanceof HotSpotMethodUnresolved)) {
+            return false;
+        }
+        HotSpotMethodUnresolved that = (HotSpotMethodUnresolved) obj;
+        return this.name.equals(that.name) && this.signature.equals(that.signature) && this.holder.equals(that.holder);
+    }
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java	Thu Mar 06 15:56:05 2014 -0800
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java	Thu Mar 06 16:24:47 2014 -0800
@@ -114,7 +114,7 @@
     /**
      * Gets the metaspace Klass for this type.
      */
-    public long metaspaceKlass() {
+    private long metaspaceKlass() {
         return HotSpotGraalRuntime.unsafeReadWord(javaClass, runtime().getConfig().klassOffset);
     }
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotUnresolvedField.java	Thu Mar 06 15:56:05 2014 -0800
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotUnresolvedField.java	Thu Mar 06 16:24:47 2014 -0800
@@ -57,6 +57,23 @@
         return holder;
     }
 
+    @Override
+    public int hashCode() {
+        return super.hashCode();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null || !(obj instanceof HotSpotUnresolvedField)) {
+            return false;
+        }
+        HotSpotUnresolvedField that = (HotSpotUnresolvedField) obj;
+        return this.holder.equals(that.holder) && this.name.equals(that.name) && this.type.equals(that.type);
+    }
+
     /**
      * Converts this compiler interface field to a string.
      */
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotUnresolvedJavaType.java	Thu Mar 06 15:56:05 2014 -0800
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotUnresolvedJavaType.java	Thu Mar 06 16:24:47 2014 -0800
@@ -95,8 +95,14 @@
     }
 
     @Override
-    public boolean equals(Object o) {
-        HotSpotUnresolvedJavaType that = (HotSpotUnresolvedJavaType) o;
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null || !(obj instanceof HotSpotUnresolvedJavaType)) {
+            return false;
+        }
+        HotSpotUnresolvedJavaType that = (HotSpotUnresolvedJavaType) obj;
         return this.simpleName.equals(that.simpleName) && this.dimensions == that.dimensions;
     }
 
--- a/src/share/vm/graal/graalCompiler.cpp	Thu Mar 06 15:56:05 2014 -0800
+++ b/src/share/vm/graal/graalCompiler.cpp	Thu Mar 06 16:24:47 2014 -0800
@@ -211,46 +211,6 @@
   TRACE_graal_1("GraalCompiler::print_timers");
 }
 
-KlassHandle GraalCompiler::get_KlassFromSignature(Symbol* signature, KlassHandle loading_klass) {
-  BasicType field_type = FieldType::basic_type(signature);
-  // If the field is a pointer type, get the klass of the field.
-  if (field_type == T_OBJECT || field_type == T_ARRAY) {
-    return GraalEnv::get_klass_by_name(loading_klass, signature, false);
-  }
-  return NULL;
-}
-
-KlassHandle GraalCompiler::get_Klass(constantPoolHandle cp, int index, KlassHandle loading_klass, Symbol*& klass_name) {
-  bool is_accessible = false;
-
-  KlassHandle klass = GraalEnv::get_klass_by_index(cp, index, is_accessible, loading_klass);
-  if (klass.is_null()) {
-    klass_name = NULL;
-    {
-      // We have to lock the cpool to keep the oop from being resolved
-      // while we are accessing it. But we must release the lock before
-      // calling up into Java.
-      MonitorLockerEx ml(cp->lock());
-      constantTag tag = cp->tag_at(index);
-      if (tag.is_klass()) {
-        // The klass has been inserted into the constant pool
-        // very recently.
-        klass = cp->resolved_klass_at(index);
-        klass_name = klass->name();
-        return klass;
-      } else if (tag.is_symbol()) {
-        klass_name = cp->symbol_at(index);
-      } else {
-        assert(cp->tag_at(index).is_unresolved_klass(), "wrong tag");
-        klass_name = cp->unresolved_klass_at(index);
-      }
-    }
-  } else {
-    klass_name = klass->name();
-  }
-  return klass;
-}
-
 BasicType GraalCompiler::kindToBasicType(jchar ch) {
   switch(ch) {
     case 'z': return T_BOOLEAN;
--- a/src/share/vm/graal/graalCompiler.hpp	Thu Mar 06 15:56:05 2014 -0800
+++ b/src/share/vm/graal/graalCompiler.hpp	Thu Mar 06 16:24:47 2014 -0800
@@ -71,9 +71,6 @@
   // Print compilation timers and statistics
   virtual void print_timers();
 
-  static KlassHandle get_KlassFromSignature(Symbol* signature, KlassHandle loading_klass);
-  static KlassHandle get_Klass(constantPoolHandle cp, int index, KlassHandle accessor, Symbol*& klass_name);
-
   void exit();
 
   static BasicType kindToBasicType(jchar ch);
--- a/src/share/vm/graal/graalCompilerToVM.cpp	Thu Mar 06 15:56:05 2014 -0800
+++ b/src/share/vm/graal/graalCompilerToVM.cpp	Thu Mar 06 16:24:47 2014 -0800
@@ -237,6 +237,13 @@
   return (jlong) (address) resolved_klass;
 C2V_END
 
+C2V_VMENTRY(jlong, lookupKlassByName, (JNIEnv *env, jobject, jstring name, jclass loading_class))
+  KlassHandle loading_klass = java_lang_Class::as_Klass(JNIHandles::resolve(loading_class));
+  Symbol* name_symbol = java_lang_String::as_symbol(JNIHandles::resolve(name), THREAD);
+  KlassHandle klass = GraalEnv::get_klass_by_name(loading_klass, name_symbol, false);
+  return (jlong) (address) klass();
+C2V_END
+
 C2V_VMENTRY(jobject, lookupConstantInPool, (JNIEnv *env, jobject, jlong metaspace_constant_pool, jint index))
   ConstantPool* cp = (ConstantPool*) metaspace_constant_pool;
   oop result = NULL;
@@ -257,48 +264,62 @@
   return JNIHandles::make_local(THREAD, result);
 C2V_END
 
+C2V_VMENTRY(jint, lookupNameAndTypeRefIndexInPool, (JNIEnv *env, jobject, jlong metaspace_constant_pool, jint index))
+  constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool;
+  return cp->name_and_type_ref_index_at(index);
+C2V_END
+
+C2V_VMENTRY(jlong, lookupNameRefInPool, (JNIEnv *env, jobject, jlong metaspace_constant_pool, jint index))
+  constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool;
+  return (jlong) (address) cp->name_ref_at(index);
+C2V_END
+
+C2V_VMENTRY(jlong, lookupSignatureRefInPool, (JNIEnv *env, jobject, jlong metaspace_constant_pool, jint index))
+  constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool;
+  return (jlong) (address) cp->signature_ref_at(index);
+C2V_END
+
+C2V_VMENTRY(jint, lookupKlassRefIndexInPool, (JNIEnv *env, jobject, jlong metaspace_constant_pool, jint index))
+  constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool;
+  return cp->klass_ref_index_at(index);
+C2V_END
+
+C2V_VMENTRY(jlong, lookupKlassInPool, (JNIEnv *env, jobject, jlong metaspace_constant_pool, jint index, jbyte opcode))
+  constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool;
+  KlassHandle loading_klass(cp->pool_holder());
+  bool is_accessible = false;
+  KlassHandle klass = GraalEnv::get_klass_by_index(cp, index, is_accessible, loading_klass);
+  if (klass.is_null()) {
+    // We have to lock the cpool to keep the oop from being resolved
+    // while we are accessing it.
+    MonitorLockerEx ml(cp->lock());
+    constantTag tag = cp->tag_at(index);
+    if (tag.is_klass()) {
+      // The klass has been inserted into the constant pool
+      // very recently.
+      return (jlong) CompilerToVM::tag_pointer(cp->resolved_klass_at(index));
+    } else if (tag.is_symbol()) {
+      return (jlong) CompilerToVM::tag_pointer(cp->symbol_at(index));
+    } else {
+      assert(cp->tag_at(index).is_unresolved_klass(), "wrong tag");
+      return (jlong) CompilerToVM::tag_pointer(cp->unresolved_klass_at(index));
+    }
+  }
+  return (jlong) CompilerToVM::tag_pointer(klass());
+C2V_END
+
 C2V_VMENTRY(jobject, lookupAppendixInPool, (JNIEnv *env, jobject, jlong metaspace_constant_pool, jint index))
   constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool;
   oop appendix_oop = ConstantPool::appendix_at_if_loaded(cp, index);
   return JNIHandles::make_local(THREAD, appendix_oop);
 C2V_END
 
-C2V_VMENTRY(jlong, lookupMethodInPool, (JNIEnv *env, jobject, jlong metaspace_constant_pool, jint index, jbyte opcode, jlongArray unresolvedInfo_handle))
+C2V_VMENTRY(jlong, lookupMethodInPool, (JNIEnv *env, jobject, jlong metaspace_constant_pool, jint index, jbyte opcode))
   constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool;
   instanceKlassHandle pool_holder(cp->pool_holder());
-
   Bytecodes::Code bc = (Bytecodes::Code) (((int) opcode) & 0xFF);
-
   methodHandle method = GraalEnv::get_method_by_index(cp, index, bc, pool_holder);
-  if (!method.is_null()) {
-    return (jlong) method();
-  } else {
-    // Get the unresolved method's name and signature.
-    typeArrayOop unresolvedInfo = (typeArrayOop) JNIHandles::resolve(unresolvedInfo_handle);
-    assert(unresolvedInfo != NULL && unresolvedInfo->length() == 4, "must be");
-    unresolvedInfo->long_at_put(0, (jlong) cp->name_ref_at(index));
-    unresolvedInfo->long_at_put(1, (jlong) cp->signature_ref_at(index));
-    Handle type;
-    if (bc != Bytecodes::_invokedynamic) {
-      int holder_index = cp->klass_ref_index_at(index);
-      Symbol* klass_name = NULL;
-      KlassHandle klass = GraalCompiler::get_Klass(cp, holder_index, cp->pool_holder(), klass_name);
-      unresolvedInfo->long_at_put(2, (jlong) klass_name);
-      unresolvedInfo->long_at_put(3, (jlong) klass());
-    } else {
-      unresolvedInfo->long_at_put(3, (jlong) SystemDictionary::MethodHandle_klass());
-    }
-    return 0L;
-  }
-C2V_END
-
-C2V_VMENTRY(jlong, lookupTypeInPool, (JNIEnv *env, jobject, jlong metaspace_constant_pool, jint index, jlongArray unresolvedTypeName_handle))
-  ConstantPool* cp = (ConstantPool*) metaspace_constant_pool;
-  Symbol* klass_name = NULL;
-  KlassHandle klass = GraalCompiler::get_Klass(cp, index, cp->pool_holder(), klass_name);
-  typeArrayOop unresolvedTypeName = (typeArrayOop) JNIHandles::resolve(unresolvedTypeName_handle);
-  unresolvedTypeName->long_at_put(0, (jlong) klass_name);
-  return (jlong) klass();
+  return (jlong) (address) method();
 C2V_END
 
 C2V_VMENTRY(void, loadReferencedTypeInPool, (JNIEnv *env, jobject, jlong metaspace_constant_pool, jint index, jbyte op))
@@ -323,44 +344,17 @@
   }
 C2V_END
 
-C2V_VMENTRY(jboolean, lookupFieldInPool, (JNIEnv *env, jobject, jlong metaspace_constant_pool, jint index, jbyte opcode, jlongArray info_handle))
+C2V_VMENTRY(jlong, resolveField, (JNIEnv *env, jobject, jlong metaspace_constant_pool, jint index, jbyte opcode, jlongArray info_handle))
   ResourceMark rm;
-
   constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool;
-
-  int nt_index = cp->name_and_type_ref_index_at(index);
-  int type_index = cp->signature_ref_index_at(nt_index);
-  Symbol* type_name = cp->symbol_at(type_index);
-  int name_index = cp->name_ref_index_at(nt_index);
-  Symbol* name = cp->symbol_at(name_index);
-  int holder_index = cp->klass_ref_index_at(index);
-  Symbol* holder_name = NULL;
-  KlassHandle holder = GraalCompiler::get_Klass(cp, holder_index, cp->pool_holder(), holder_name);
-  KlassHandle type = GraalCompiler::get_KlassFromSignature(type_name, cp->pool_holder());
+  Bytecodes::Code code = (Bytecodes::Code)(((int) opcode) & 0xFF);
+  fieldDescriptor result;
+  LinkResolver::resolve_field_access(result, cp, index, Bytecodes::java_code(code), true, false, CHECK_0);
   typeArrayOop info = (typeArrayOop) JNIHandles::resolve(info_handle);
-  assert(info != NULL && info->length() == 7, "must be");
-  info->long_at_put(0, (jlong) name);
-  info->long_at_put(1, (jlong) type_name);
-  info->long_at_put(2, (jlong) type());
-  info->long_at_put(3, (jlong) holder_name);
-  info->long_at_put(4, (jlong) holder());
-
-  Bytecodes::Code code = (Bytecodes::Code)(((int) opcode) & 0xFF);
-  if (!holder.is_null()) {
-    int offset = -1;
-    fieldDescriptor result;
-    LinkResolver::resolve_field_access(result, cp, index, Bytecodes::java_code(code), true, false, Thread::current());
-
-    if (HAS_PENDING_EXCEPTION) {
-      CLEAR_PENDING_EXCEPTION;
-    } else {
-      info->long_at_put(4, (jlong) result.field_holder());
-      info->long_at_put(5, (jlong) result.access_flags().as_int());
-      info->long_at_put(6, (jlong) result.offset());
-      return true;
-    }
-  }
-  return false;
+  assert(info != NULL && info->length() == 2, "must be");
+  info->long_at_put(0, (jlong) result.access_flags().as_int());
+  info->long_at_put(1, (jlong) result.offset());
+  return (jlong) (address) result.field_holder();
 C2V_END
 
 C2V_VMENTRY(jlong, resolveMethod, (JNIEnv *, jobject, jobject resolved_type, jstring name, jstring signature))
@@ -368,15 +362,7 @@
   Klass* klass = java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaClass(resolved_type));
   Symbol* name_symbol = java_lang_String::as_symbol(JNIHandles::resolve(name), THREAD);
   Symbol* signature_symbol = java_lang_String::as_symbol(JNIHandles::resolve(signature), THREAD);
-  Method* method = klass->lookup_method(name_symbol, signature_symbol);
-  if (method == NULL) {
-    if (TraceGraal >= 3) {
-      ResourceMark rm;
-      tty->print_cr("Could not resolve method %s %s on klass %s", name_symbol->as_C_string(), signature_symbol->as_C_string(), klass->name()->as_C_string());
-    }
-    return 0;
-  }
-  return (jlong) (address) method;
+  return (jlong) (address) klass->lookup_method(name_symbol, signature_symbol);
 C2V_END
 
 C2V_VMENTRY(jboolean, hasFinalizableSubclass,(JNIEnv *, jobject, jobject hotspot_klass))
@@ -859,50 +845,56 @@
 #define METASPACE_METHOD      "J"
 #define METASPACE_METHOD_DATA "J"
 #define METASPACE_CONSTANT_POOL "J"
+#define METASPACE_SYMBOL      "J"
 
 JNINativeMethod CompilerToVM_methods[] = {
-  {CC"initializeBytecode",            CC"("METASPACE_METHOD"[B)[B",                                     FN_PTR(initializeBytecode)},
-  {CC"exceptionTableStart",           CC"("METASPACE_METHOD")J",                                        FN_PTR(exceptionTableStart)},
-  {CC"hasBalancedMonitors",           CC"("METASPACE_METHOD")Z",                                        FN_PTR(hasBalancedMonitors)},
-  {CC"findUniqueConcreteMethod",      CC"("METASPACE_METHOD")"METASPACE_METHOD,                         FN_PTR(findUniqueConcreteMethod)},
-  {CC"getKlassImplementor",           CC"("METASPACE_KLASS")"METASPACE_KLASS,                           FN_PTR(getKlassImplementor)},
-  {CC"getStackTraceElement",          CC"("METASPACE_METHOD"I)"STACK_TRACE_ELEMENT,                     FN_PTR(getStackTraceElement)},
-  {CC"initializeMethod",              CC"("METASPACE_METHOD HS_RESOLVED_METHOD")V",                     FN_PTR(initializeMethod)},
-  {CC"doNotInlineOrCompile",          CC"("METASPACE_METHOD")V",                                        FN_PTR(doNotInlineOrCompile)},
-  {CC"canInlineMethod",               CC"("METASPACE_METHOD")Z",                                        FN_PTR(canInlineMethod)},
-  {CC"shouldInlineMethod",            CC"("METASPACE_METHOD")Z",                                        FN_PTR(shouldInlineMethod)},
-  {CC"getCompiledCodeSize",           CC"("METASPACE_METHOD")I",                                        FN_PTR(getCompiledCodeSize)},
-  {CC"lookupType",                    CC"("STRING CLASS"Z)"METASPACE_KLASS,                             FN_PTR(lookupType)},
-  {CC"lookupConstantInPool",          CC"("METASPACE_CONSTANT_POOL"I)"OBJECT,                           FN_PTR(lookupConstantInPool)},
-  {CC"lookupAppendixInPool",          CC"("METASPACE_CONSTANT_POOL"I)"OBJECT,                           FN_PTR(lookupAppendixInPool)},
-  {CC"lookupMethodInPool",            CC"("METASPACE_CONSTANT_POOL"IB[J)"METASPACE_METHOD,              FN_PTR(lookupMethodInPool)},
-  {CC"lookupTypeInPool",              CC"("METASPACE_CONSTANT_POOL"I[J)"METASPACE_KLASS,                FN_PTR(lookupTypeInPool)},
-  {CC"loadReferencedTypeInPool",      CC"("METASPACE_CONSTANT_POOL"IB)V",                               FN_PTR(loadReferencedTypeInPool)},
-  {CC"lookupFieldInPool",             CC"("METASPACE_CONSTANT_POOL"IB[J)Z",                             FN_PTR(lookupFieldInPool)},
-  {CC"resolveMethod",                 CC"("HS_RESOLVED_TYPE STRING STRING")"METASPACE_METHOD,           FN_PTR(resolveMethod)},
-  {CC"getClassInitializer",           CC"("HS_RESOLVED_TYPE")"METASPACE_METHOD,                         FN_PTR(getClassInitializer)},
-  {CC"hasFinalizableSubclass",        CC"("HS_RESOLVED_TYPE")Z",                                        FN_PTR(hasFinalizableSubclass)},
-  {CC"getMaxCallTargetOffset",        CC"(J)J",                                                         FN_PTR(getMaxCallTargetOffset)},
-  {CC"getMetaspaceMethod",            CC"("CLASS"I)"METASPACE_METHOD,                                   FN_PTR(getMetaspaceMethod)},
-  {CC"initializeConfiguration",       CC"("HS_CONFIG")V",                                               FN_PTR(initializeConfiguration)},
-  {CC"installCode0",                  CC"("HS_COMPILED_CODE HS_INSTALLED_CODE SPECULATION_LOG")I",      FN_PTR(installCode0)},
-  {CC"notifyCompilationStatistics",   CC"(I"HS_RESOLVED_METHOD"ZIJJ"HS_INSTALLED_CODE")V",              FN_PTR(notifyCompilationStatistics)},
-  {CC"printCompilationStatistics",    CC"(ZZ)V",                                                        FN_PTR(printCompilationStatistics)},
-  {CC"resetCompilationStatistics",    CC"()V",                                                          FN_PTR(resetCompilationStatistics)},
-  {CC"disassembleCodeBlob",           CC"(J)"STRING,                                                    FN_PTR(disassembleCodeBlob)},
-  {CC"executeCompiledMethodVarargs",  CC"(["OBJECT HS_INSTALLED_CODE")"OBJECT,                          FN_PTR(executeCompiledMethodVarargs)},
-  {CC"getDeoptedLeafGraphIds",        CC"()[J",                                                         FN_PTR(getDeoptedLeafGraphIds)},
-  {CC"getLineNumberTable",            CC"("HS_RESOLVED_METHOD")[J",                                     FN_PTR(getLineNumberTable)},
-  {CC"getLocalVariableTableStart",    CC"("HS_RESOLVED_METHOD")J",                                      FN_PTR(getLocalVariableTableStart)},
-  {CC"getLocalVariableTableLength",   CC"("HS_RESOLVED_METHOD")I",                                      FN_PTR(getLocalVariableTableLength)},
-  {CC"reprofile",                     CC"("METASPACE_METHOD")V",                                        FN_PTR(reprofile)},
-  {CC"invalidateInstalledCode",       CC"("HS_INSTALLED_CODE")V",                                       FN_PTR(invalidateInstalledCode)},
-  {CC"readUnsafeUncompressedPointer", CC"("OBJECT"J)"OBJECT,                                            FN_PTR(readUnsafeUncompressedPointer)},
-  {CC"readUnsafeKlassPointer",        CC"("OBJECT")J",                                                  FN_PTR(readUnsafeKlassPointer)},
-  {CC"collectCounters",               CC"()[J",                                                         FN_PTR(collectCounters)},
-  {CC"getGPUs",                       CC"()"STRING,                                                     FN_PTR(getGPUs)},
-  {CC"allocateCompileId",             CC"("HS_RESOLVED_METHOD"I)I",                                     FN_PTR(allocateCompileId)},
-  {CC"isMature",                      CC"("METASPACE_METHOD_DATA")Z",                                   FN_PTR(isMature)},
+  {CC"initializeBytecode",              CC"("METASPACE_METHOD"[B)[B",                                     FN_PTR(initializeBytecode)},
+  {CC"exceptionTableStart",             CC"("METASPACE_METHOD")J",                                        FN_PTR(exceptionTableStart)},
+  {CC"hasBalancedMonitors",             CC"("METASPACE_METHOD")Z",                                        FN_PTR(hasBalancedMonitors)},
+  {CC"findUniqueConcreteMethod",        CC"("METASPACE_METHOD")"METASPACE_METHOD,                         FN_PTR(findUniqueConcreteMethod)},
+  {CC"getKlassImplementor",             CC"("METASPACE_KLASS")"METASPACE_KLASS,                           FN_PTR(getKlassImplementor)},
+  {CC"getStackTraceElement",            CC"("METASPACE_METHOD"I)"STACK_TRACE_ELEMENT,                     FN_PTR(getStackTraceElement)},
+  {CC"initializeMethod",                CC"("METASPACE_METHOD HS_RESOLVED_METHOD")V",                     FN_PTR(initializeMethod)},
+  {CC"doNotInlineOrCompile",            CC"("METASPACE_METHOD")V",                                        FN_PTR(doNotInlineOrCompile)},
+  {CC"canInlineMethod",                 CC"("METASPACE_METHOD")Z",                                        FN_PTR(canInlineMethod)},
+  {CC"shouldInlineMethod",              CC"("METASPACE_METHOD")Z",                                        FN_PTR(shouldInlineMethod)},
+  {CC"getCompiledCodeSize",             CC"("METASPACE_METHOD")I",                                        FN_PTR(getCompiledCodeSize)},
+  {CC"lookupType",                      CC"("STRING CLASS"Z)"METASPACE_KLASS,                             FN_PTR(lookupType)},
+  {CC"lookupKlassByName",               CC"("STRING CLASS")"METASPACE_KLASS,                              FN_PTR(lookupKlassByName)},
+  {CC"lookupConstantInPool",            CC"("METASPACE_CONSTANT_POOL"I)"OBJECT,                           FN_PTR(lookupConstantInPool)},
+  {CC"lookupNameRefInPool",             CC"("METASPACE_CONSTANT_POOL"I)"METASPACE_SYMBOL,                 FN_PTR(lookupNameRefInPool)},
+  {CC"lookupNameAndTypeRefIndexInPool", CC"("METASPACE_CONSTANT_POOL"I)I",                                FN_PTR(lookupNameAndTypeRefIndexInPool)},
+  {CC"lookupSignatureRefInPool",        CC"("METASPACE_CONSTANT_POOL"I)"METASPACE_SYMBOL,                 FN_PTR(lookupSignatureRefInPool)},
+  {CC"lookupKlassRefIndexInPool",       CC"("METASPACE_CONSTANT_POOL"I)I",                                FN_PTR(lookupKlassRefIndexInPool)},
+  {CC"lookupKlassInPool",               CC"("METASPACE_CONSTANT_POOL"I)"METASPACE_KLASS,                  FN_PTR(lookupKlassInPool)},
+  {CC"lookupAppendixInPool",            CC"("METASPACE_CONSTANT_POOL"I)"OBJECT,                           FN_PTR(lookupAppendixInPool)},
+  {CC"lookupMethodInPool",              CC"("METASPACE_CONSTANT_POOL"IB)"METASPACE_METHOD,                FN_PTR(lookupMethodInPool)},
+  {CC"loadReferencedTypeInPool",        CC"("METASPACE_CONSTANT_POOL"IB)V",                               FN_PTR(loadReferencedTypeInPool)},
+  {CC"resolveField",                    CC"("METASPACE_CONSTANT_POOL"IB[J)"METASPACE_KLASS,               FN_PTR(resolveField)},
+  {CC"resolveMethod",                   CC"("HS_RESOLVED_TYPE STRING STRING")"METASPACE_METHOD,           FN_PTR(resolveMethod)},
+  {CC"getClassInitializer",             CC"("HS_RESOLVED_TYPE")"METASPACE_METHOD,                         FN_PTR(getClassInitializer)},
+  {CC"hasFinalizableSubclass",          CC"("HS_RESOLVED_TYPE")Z",                                        FN_PTR(hasFinalizableSubclass)},
+  {CC"getMaxCallTargetOffset",          CC"(J)J",                                                         FN_PTR(getMaxCallTargetOffset)},
+  {CC"getMetaspaceMethod",              CC"("CLASS"I)"METASPACE_METHOD,                                   FN_PTR(getMetaspaceMethod)},
+  {CC"initializeConfiguration",         CC"("HS_CONFIG")V",                                               FN_PTR(initializeConfiguration)},
+  {CC"installCode0",                    CC"("HS_COMPILED_CODE HS_INSTALLED_CODE SPECULATION_LOG")I",      FN_PTR(installCode0)},
+  {CC"notifyCompilationStatistics",     CC"(I"HS_RESOLVED_METHOD"ZIJJ"HS_INSTALLED_CODE")V",              FN_PTR(notifyCompilationStatistics)},
+  {CC"printCompilationStatistics",      CC"(ZZ)V",                                                        FN_PTR(printCompilationStatistics)},
+  {CC"resetCompilationStatistics",      CC"()V",                                                          FN_PTR(resetCompilationStatistics)},
+  {CC"disassembleCodeBlob",             CC"(J)"STRING,                                                    FN_PTR(disassembleCodeBlob)},
+  {CC"executeCompiledMethodVarargs",    CC"(["OBJECT HS_INSTALLED_CODE")"OBJECT,                          FN_PTR(executeCompiledMethodVarargs)},
+  {CC"getDeoptedLeafGraphIds",          CC"()[J",                                                         FN_PTR(getDeoptedLeafGraphIds)},
+  {CC"getLineNumberTable",              CC"("HS_RESOLVED_METHOD")[J",                                     FN_PTR(getLineNumberTable)},
+  {CC"getLocalVariableTableStart",      CC"("HS_RESOLVED_METHOD")J",                                      FN_PTR(getLocalVariableTableStart)},
+  {CC"getLocalVariableTableLength",     CC"("HS_RESOLVED_METHOD")I",                                      FN_PTR(getLocalVariableTableLength)},
+  {CC"reprofile",                       CC"("METASPACE_METHOD")V",                                        FN_PTR(reprofile)},
+  {CC"invalidateInstalledCode",         CC"("HS_INSTALLED_CODE")V",                                       FN_PTR(invalidateInstalledCode)},
+  {CC"readUnsafeUncompressedPointer",   CC"("OBJECT"J)"OBJECT,                                            FN_PTR(readUnsafeUncompressedPointer)},
+  {CC"readUnsafeKlassPointer",          CC"("OBJECT")J",                                                  FN_PTR(readUnsafeKlassPointer)},
+  {CC"collectCounters",                 CC"()[J",                                                         FN_PTR(collectCounters)},
+  {CC"getGPUs",                         CC"()"STRING,                                                     FN_PTR(getGPUs)},
+  {CC"allocateCompileId",               CC"("HS_RESOLVED_METHOD"I)I",                                     FN_PTR(allocateCompileId)},
+  {CC"isMature",                        CC"("METASPACE_METHOD_DATA")Z",                                   FN_PTR(isMature)},
 };
 
 int CompilerToVM_methods_count() {
--- a/src/share/vm/graal/graalCompilerToVM.hpp	Thu Mar 06 15:56:05 2014 -0800
+++ b/src/share/vm/graal/graalCompilerToVM.hpp	Thu Mar 06 16:24:47 2014 -0800
@@ -27,6 +27,27 @@
 #include "prims/jni.h"
 #include "runtime/javaCalls.hpp"
 
+class CompilerToVM {
+public:
+  /**
+   * Tag bits used by lookupKlassInPool to distinguish the types in Java.
+   */
+  enum Tags {
+    KLASS_TAG = 0x0,
+    SYMBOL_TAG = 0x1
+  };
+
+  static intptr_t tag_pointer(Klass* klass) {
+    return ((intptr_t) klass) | KLASS_TAG;
+  }
+
+  static intptr_t tag_pointer(Symbol* symbol) {
+    return ((intptr_t) symbol) | SYMBOL_TAG;
+  }
+
+  // nothing here - no need to define the jni method implementations in a header file
+};
+
 extern JNINativeMethod CompilerToVM_methods[];
 int CompilerToVM_methods_count();
 
@@ -89,6 +110,4 @@
   inline void do_void()                     { }
 };
 
-// nothing here - no need to define the jni method implementations in a header file
-
 #endif // SHARE_VM_GRAAL_GRAAL_COMPILER_TO_VM_HPP
--- a/src/share/vm/graal/vmStructs_graal.hpp	Thu Mar 06 15:56:05 2014 -0800
+++ b/src/share/vm/graal/vmStructs_graal.hpp	Thu Mar 06 16:24:47 2014 -0800
@@ -26,6 +26,7 @@
 #define SHARE_VM_GRAAL_VMSTRUCTS_GRAAL_HPP
 
 #include "compiler/abstractCompiler.hpp"
+#include "graal/graalCompilerToVM.hpp"
 #include "graal/graalEnv.hpp"
 
 #define VM_STRUCTS_GRAAL(nonstatic_field, static_field)                       \
@@ -43,5 +44,8 @@
                                                                                                   \
   declare_preprocessor_constant("JVM_ACC_SYNTHETIC", JVM_ACC_SYNTHETIC)                           \
   declare_preprocessor_constant("JVM_RECOGNIZED_FIELD_MODIFIERS", JVM_RECOGNIZED_FIELD_MODIFIERS) \
+                                                                                                  \
+  declare_constant(CompilerToVM::KLASS_TAG)                                                       \
+  declare_constant(CompilerToVM::SYMBOL_TAG)                                                      \
 
 #endif // SHARE_VM_GRAAL_VMSTRUCTS_GRAAL_HPP