# HG changeset patch # User Gilles Duboscq # Date 1378224542 -7200 # Node ID 7cca436d600bb9278fc255cfa3f040b39d664684 # Parent a3b39ab7c453fc5d11d2dbd839d095829d06c7e0 Add isLinked method to ResolvedJavaType diff -r a3b39ab7c453 -r 7cca436d600b graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestResolvedJavaType.java --- 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", diff -r a3b39ab7c453 -r 7cca436d600b graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaType.java --- 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. diff -r a3b39ab7c453 -r 7cca436d600b graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java --- 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); } diff -r a3b39ab7c453 -r 7cca436d600b graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java --- 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); diff -r a3b39ab7c453 -r 7cca436d600b graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java --- 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; } diff -r a3b39ab7c453 -r 7cca436d600b graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java --- 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; diff -r a3b39ab7c453 -r 7cca436d600b src/share/vm/graal/graalCompilerToVM.cpp --- 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)},