changeset 11520:7cca436d600b

Add isLinked method to ResolvedJavaType
author Gilles Duboscq <duboscq@ssw.jku.at>
date Tue, 03 Sep 2013 18:09:02 +0200
parents a3b39ab7c453
children f521a1db1378
files graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestResolvedJavaType.java graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaType.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java src/share/vm/graal/graalCompilerToVM.cpp
diffstat 7 files changed, 36 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestResolvedJavaType.java	Tue Sep 03 18:02:29 2013 +0200
+++ b/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestResolvedJavaType.java	Tue Sep 03 18:09:02 2013 +0200
@@ -594,6 +594,7 @@
         "getDeclaredMethods",
         "getDeclaredConstructors",
         "isInitialized",
+        "isLinked",
         "getEncoding",
         "hasFinalizableSubclass",
         "hasFinalizer",
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaType.java	Tue Sep 03 18:02:29 2013 +0200
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaType.java	Tue Sep 03 18:09:02 2013 +0200
@@ -112,7 +112,8 @@
     int getModifiers();
 
     /**
-     * Checks whether this type is initialized.
+     * Checks whether this type is initialized. If a type is initialized it implies that is was
+     * {@link #isLinked() linked} and that the static initializer has run.
      * 
      * @return {@code true} if this type is initialized
      */
@@ -124,6 +125,14 @@
     void initialize();
 
     /**
+     * Checks whether this type is linked and verified. When a type is linked the static initializer
+     * has not necessarily run. An {@link #isInitialized() initialized} type is always linked.
+     * 
+     * @return {@code true} if this type is linked
+     */
+    boolean isLinked();
+
+    /**
      * Determines if this type is either the same as, or is a superclass or superinterface of, the
      * type represented by the specified parameter. This method is identical to
      * {@link Class#isAssignableFrom(Class)} in terms of the value return for this type.
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java	Tue Sep 03 18:02:29 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java	Tue Sep 03 18:09:02 2013 +0200
@@ -226,4 +226,6 @@
     void reprofile(long metaspaceMethod);
 
     void invalidateInstalledCode(HotSpotInstalledCode hotspotInstalledCode);
+
+    boolean isTypeLinked(HotSpotResolvedObjectType hotSpotResolvedObjectType);
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java	Tue Sep 03 18:02:29 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java	Tue Sep 03 18:09:02 2013 +0200
@@ -102,6 +102,8 @@
     @Override
     public native boolean isTypeInitialized(HotSpotResolvedObjectType klass);
 
+    public native boolean isTypeLinked(HotSpotResolvedObjectType hotSpotResolvedObjectType);
+
     @Override
     public native boolean hasFinalizableSubclass(HotSpotResolvedObjectType klass);
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java	Tue Sep 03 18:02:29 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java	Tue Sep 03 18:09:02 2013 +0200
@@ -83,6 +83,7 @@
     private ResolvedJavaType[] interfaces;
     private ConstantPool constantPool;
     private boolean isInitialized;
+    private boolean isLinked;
     private ResolvedJavaType arrayOfType;
 
     /**
@@ -292,9 +293,18 @@
     }
 
     @Override
+    public boolean isLinked() {
+        if (!isLinked) {
+            isLinked = graalRuntime().getCompilerToVM().isTypeLinked(this);
+        }
+        return isLinked;
+    }
+
+    @Override
     public void initialize() {
         if (!isInitialized) {
             graalRuntime().getCompilerToVM().initializeType(this);
+            assert graalRuntime().getCompilerToVM().isTypeInitialized(this);
         }
         isInitialized = true;
     }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java	Tue Sep 03 18:02:29 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java	Tue Sep 03 18:09:02 2013 +0200
@@ -112,6 +112,10 @@
         return true;
     }
 
+    public boolean isLinked() {
+        return true;
+    }
+
     @Override
     public boolean isInstance(Constant obj) {
         return false;
--- a/src/share/vm/graal/graalCompilerToVM.cpp	Tue Sep 03 18:02:29 2013 +0200
+++ b/src/share/vm/graal/graalCompilerToVM.cpp	Tue Sep 03 18:09:02 2013 +0200
@@ -554,6 +554,12 @@
   return InstanceKlass::cast(klass)->is_initialized();
 C2V_END
 
+C2V_VMENTRY(jboolean, isTypeLinked,(JNIEnv *, jobject, jobject hotspot_klass))
+  Klass* klass = java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaMirror(hotspot_klass));
+  assert(klass != NULL, "method must not be called for primitive types");
+  return InstanceKlass::cast(klass)->is_linked();
+C2V_END
+
 C2V_VMENTRY(jboolean, hasFinalizableSubclass,(JNIEnv *, jobject, jobject hotspot_klass))
   Klass* klass = java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaMirror(hotspot_klass));
   assert(klass != NULL, "method must not be called for primitive types");
@@ -1198,6 +1204,7 @@
   {CC"getInstanceFields",             CC"("HS_RESOLVED_TYPE")["HS_RESOLVED_FIELD,                       FN_PTR(getInstanceFields)},
   {CC"getMethods",                    CC"("HS_RESOLVED_TYPE")["HS_RESOLVED_METHOD,                      FN_PTR(getMethods)},
   {CC"isTypeInitialized",             CC"("HS_RESOLVED_TYPE")Z",                                        FN_PTR(isTypeInitialized)},
+  {CC"isTypeLinked",                  CC"("HS_RESOLVED_TYPE")Z",                                        FN_PTR(isTypeLinked)},
   {CC"hasFinalizableSubclass",        CC"("HS_RESOLVED_TYPE")Z",                                        FN_PTR(hasFinalizableSubclass)},
   {CC"initializeType",                CC"("HS_RESOLVED_TYPE")V",                                        FN_PTR(initializeType)},
   {CC"getMaxCallTargetOffset",        CC"(J)J",                                                         FN_PTR(getMaxCallTargetOffset)},