changeset 18558:7484f5fcd41d

removed a usages of HotSpotGraalRuntime.unsafeReadWord(); tidied up some comments
author Doug Simon <doug.simon@oracle.com>
date Wed, 26 Nov 2014 22:58:09 +0100
parents 80a6b4a23418
children a2ee2e329af8
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectTypeImpl.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java
diffstat 3 files changed, 12 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java	Wed Nov 26 22:39:03 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java	Wed Nov 26 22:58:09 2014 +0100
@@ -390,7 +390,7 @@
         // If the name represents a primitive type we can short-circuit the lookup.
         if (name.length() == 1) {
             Kind kind = Kind.fromPrimitiveOrVoidTypeChar(name.charAt(0));
-            return HotSpotResolvedPrimitiveType.fromKind(kind);
+            return fromClass(kind.toJavaClass());
         }
 
         // Resolve non-primitive types in the VM.
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectTypeImpl.java	Wed Nov 26 22:39:03 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectTypeImpl.java	Wed Nov 26 22:58:09 2014 +0100
@@ -52,7 +52,7 @@
     private HotSpotResolvedJavaField[] instanceFields;
     private HotSpotResolvedObjectTypeImpl[] interfaces;
     private ConstantPool constantPool;
-    private HotSpotResolvedObjectTypeImpl arrayOfType;
+    private HotSpotResolvedObjectType arrayOfType;
 
     /**
      * Gets the Graal mirror for a {@link Class} object.
@@ -66,17 +66,6 @@
     /**
      * Gets the Graal mirror from a HotSpot metaspace Klass native object.
      *
-     * @param metaspaceKlass a metaspace Klass object boxed in a {@link JavaConstant}
-     * @return the {@link HotSpotResolvedObjectTypeImpl} corresponding to {@code klassConstant}
-     */
-    public static ResolvedJavaType fromMetaspaceKlass(Constant metaspaceKlass) {
-        HotSpotMetaspaceConstant klass = (HotSpotMetaspaceConstant) metaspaceKlass;
-        return klass.asResolvedJavaType();
-    }
-
-    /**
-     * Gets the Graal mirror from a HotSpot metaspace Klass native object.
-     *
      * @param metaspaceKlass a metaspace Klass object
      * @return the {@link ResolvedJavaType} corresponding to {@code metaspaceKlass}
      */
@@ -92,8 +81,8 @@
      *
      * <p>
      * <b>NOTE</b>: Creating an instance of this class does not install the mirror for the
-     * {@link Class} type. Use {@link #fromObjectClass(Class)},
-     * {@link #fromMetaspaceKlass(Constant)} or {@link #fromMetaspaceKlass(long)} instead.
+     * {@link Class} type. Use {@link #fromObjectClass(Class)} or {@link #fromMetaspaceKlass(long)}
+     * instead.
      * </p>
      *
      * @param javaClass the Class to create the mirror for
@@ -118,7 +107,10 @@
      * Gets the metaspace Klass for this type.
      */
     public long getMetaspaceKlass() {
-        return HotSpotGraalRuntime.unsafeReadWord(javaClass, runtime().getConfig().klassOffset);
+        if (HotSpotGraalRuntime.getHostWordKind() == Kind.Long) {
+            return unsafe.getLong(javaClass, (long) runtime().getConfig().klassOffset);
+        }
+        return unsafe.getInt(javaClass, (long) runtime().getConfig().klassOffset) & 0xFFFFFFFFL;
     }
 
     @Override
@@ -169,7 +161,7 @@
             HotSpotResolvedObjectTypeImpl type = this;
             while (type.isAbstract()) {
                 long subklass = type.getSubklass();
-                if (subklass == 0 || unsafeReadWord(subklass + config.nextSiblingOffset) != 0) {
+                if (subklass == 0 || unsafe.getAddress(subklass + config.nextSiblingOffset) != 0) {
                     return null;
                 }
                 type = fromMetaspaceKlass(subklass);
@@ -198,7 +190,7 @@
      * @return value of the subklass field as metaspace klass pointer
      */
     private long getSubklass() {
-        return unsafeReadWord(getMetaspaceKlass() + runtime().getConfig().subklassOffset);
+        return unsafe.getAddress(getMetaspaceKlass() + runtime().getConfig().subklassOffset);
     }
 
     @Override
@@ -791,7 +783,7 @@
         if (isArray()) {
             return config.arrayPrototypeMarkWord();
         } else {
-            return unsafeReadWord(getMetaspaceKlass() + config.prototypeMarkWordOffset);
+            return unsafe.getAddress(getMetaspaceKlass() + config.prototypeMarkWordOffset);
         }
     }
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java	Wed Nov 26 22:39:03 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java	Wed Nov 26 22:58:09 2014 +0100
@@ -40,21 +40,11 @@
     private final Kind kind;
 
     /**
-     * Gets the Graal mirror for a {@link Kind}.
-     *
-     * @return the {@link HotSpotResolvedObjectTypeImpl} corresponding to {@code kind}
-     */
-    public static ResolvedJavaType fromKind(Kind kind) {
-        Class<?> javaClass = kind.toJavaClass();
-        return fromClass(javaClass);
-    }
-
-    /**
      * Creates the Graal mirror for a primitive {@link Kind}.
      *
      * <p>
      * <b>NOTE</b>: Creating an instance of this class does not install the mirror for the
-     * {@link Class} type. Use {@link #fromKind(Kind)} or {@link #fromClass(Class)} instead.
+     * {@link Class} type. Use {@link #fromClass(Class)} instead.
      * </p>
      *
      * @param kind the Kind to create the mirror for