changeset 2499:ad9b14650e15

Fixed an issue with RiType.superType (wrong cast in the C++ part).
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Tue, 26 Apr 2011 16:46:23 +0200
parents 55caa3034872
children f100b972fd19
files src/share/vm/c1x/c1x_Compiler.cpp src/share/vm/c1x/c1x_VMEntries.cpp
diffstat 2 files changed, 39 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/c1x/c1x_Compiler.cpp	Tue Apr 26 14:46:28 2011 +0200
+++ b/src/share/vm/c1x/c1x_Compiler.cpp	Tue Apr 26 16:46:23 2011 +0200
@@ -104,12 +104,15 @@
   initialize_buffer_blob();
   VmIds::initializeObjects();
 
+  TRACE_C1X_2("C1XCompiler::compile_method");
+
   CompilerThread::current()->set_compiling(true);
   methodOop method = (methodOop) target->get_oop();
   VMExits::compileMethod(VmIds::add<methodOop>(method), VmIds::toString<Handle>(method->name(), THREAD), entry_bci);
   CompilerThread::current()->set_compiling(false);
 
   VmIds::cleanupLocalObjects();
+  TRACE_C1X_2("C1XCompiler::compile_method exit");
 }
 
 // Print compilation timers and statistics
--- a/src/share/vm/c1x/c1x_VMEntries.cpp	Tue Apr 26 14:46:28 2011 +0200
+++ b/src/share/vm/c1x/c1x_VMEntries.cpp	Tue Apr 26 16:46:23 2011 +0200
@@ -33,6 +33,7 @@
 
 // public byte[] RiMethod_code(long vmId);
 JNIEXPORT jbyteArray JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1code(JNIEnv *env, jobject, jlong vmId) {
+  TRACE_C1X_3("VMEntries::RiMethod_code");
   methodHandle method = VmIds::get<methodOop>(vmId);
   int code_size = method->code_size();
   jbyteArray result = env->NewByteArray(code_size);
@@ -42,16 +43,19 @@
 
 // public int RiMethod_maxStackSize(long vmId);
 JNIEXPORT jint JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1maxStackSize(JNIEnv *, jobject, jlong vmId) {
+  TRACE_C1X_3("VMEntries::RiMethod_maxStackSize");
   return VmIds::get<methodOop>(vmId)->max_stack();
 }
 
 // public int RiMethod_maxLocals(long vmId);
 JNIEXPORT jint JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1maxLocals(JNIEnv *, jobject, jlong vmId) {
+  TRACE_C1X_3("VMEntries::RiMethod_maxLocals");
   return VmIds::get<methodOop>(vmId)->max_locals();
 }
 
 // public RiType RiMethod_holder(long vmId);
 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1holder(JNIEnv *, jobject, jlong vmId) {
+  TRACE_C1X_3("VMEntries::RiMethod_holder");
   VM_ENTRY_MARK
   KlassHandle klass = VmIds::get<methodOop>(vmId)->method_holder();
   Handle name = VmIds::toString<Handle>(klass->name(), CHECK_NULL);
@@ -61,6 +65,7 @@
 
 // public String RiMethod_signature(long vmId);
 JNIEXPORT jstring JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1signature(JNIEnv *env, jobject, jlong vmId) {
+  TRACE_C1X_3("VMEntries::RiMethod_signature");
   VM_ENTRY_MARK
   methodOop method = VmIds::get<methodOop>(vmId);
   method->constMethod()->exception_table();
@@ -69,11 +74,13 @@
 
 // public int RiMethod_accessFlags(long vmId);
 JNIEXPORT jint JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1accessFlags(JNIEnv *, jobject, jlong vmId) {
+  TRACE_C1X_3("VMEntries::RiMethod_accessFlags");
   return VmIds::get<methodOop>(vmId)->access_flags().as_int();
 }
 
 // public RiExceptionHandler[] RiMethod_exceptionHandlers(long vmId);
 JNIEXPORT jobjectArray JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1exceptionHandlers(JNIEnv *, jobject, jlong vmId) {
+  TRACE_C1X_3("VMEntries::RiMethod_exceptionHandlers");
   VM_ENTRY_MARK
   methodHandle method = VmIds::get<methodOop>(vmId);
   typeArrayHandle handlers = method->exception_table();
@@ -111,6 +118,7 @@
 
 // public boolean RiMethod_hasBalancedMonitors(long vmId);
 JNIEXPORT jint JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1hasBalancedMonitors(JNIEnv *, jobject, jlong vmId) {
+  TRACE_C1X_3("VMEntries::RiMethod_hasBalancedMonitors");
   ciMethod* cimethod;
   {
     VM_ENTRY_MARK;
@@ -121,6 +129,7 @@
 
 // public boolean RiMethod_uniqueConcreteMethod(long vmId);
 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1uniqueConcreteMethod(JNIEnv *, jobject, jlong vmId) {
+  TRACE_C1X_3("VMEntries::RiMethod_uniqueConcreteMethod");
   VM_ENTRY_MARK;
   ciMethod* cimethod = (ciMethod*)CURRENT_ENV->get_object(VmIds::get<methodOop>(vmId));
   if (cimethod->holder()->is_interface()) {
@@ -152,6 +161,7 @@
 
 // public RiType RiSignature_lookupType(String returnType, HotSpotTypeResolved accessingClass);
 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiSignature_1lookupType(JNIEnv *env, jobject, jstring jname, jobject accessingClass) {
+  TRACE_C1X_3("VMEntries::RiSignature_lookupType");
   VM_ENTRY_MARK;
 
   Symbol* nameSymbol = VmIds::toSymbol(jname);
@@ -202,6 +212,7 @@
 
 // public Object RiConstantPool_lookupConstant(long vmId, int cpi);
 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupConstant(JNIEnv *env, jobject, jlong vmId, jint index) {
+  TRACE_C1X_3("VMEntries::RiConstantPool_lookupConstant");
   VM_ENTRY_MARK;
 
   constantPoolOop cp = VmIds::get<constantPoolOop>(vmId);
@@ -248,6 +259,7 @@
 
 // public RiMethod RiConstantPool_lookupMethod(long vmId, int cpi, byte byteCode);
 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupMethod(JNIEnv *env, jobject, jlong vmId, jint index, jbyte byteCode) {
+  TRACE_C1X_3("VMEntries::RiConstantPool_lookupMethod");
   VM_ENTRY_MARK;
 
   index = C1XCompiler::to_cp_index_u2(index);
@@ -276,6 +288,7 @@
 
 // public RiType RiConstantPool_lookupType(long vmId, int cpi);
 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupType(JNIEnv *env, jobject, jlong vmId, jint index) {
+  TRACE_C1X_3("VMEntries::RiConstantPool_lookupType");
   VM_ENTRY_MARK;
 
   constantPoolOop cp = VmIds::get<constantPoolOop>(vmId);
@@ -288,6 +301,7 @@
 
 // public RiField RiConstantPool_lookupField(long vmId, int cpi);
 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupField(JNIEnv *env, jobject, jlong vmId, jint index, jbyte byteCode) {
+  TRACE_C1X_3("VMEntries::RiConstantPool_lookupField");
   VM_ENTRY_MARK;
 
   index = C1XCompiler::to_cp_index_u2(index);
@@ -351,6 +365,7 @@
 
 // public RiConstantPool RiType_constantPool(HotSpotTypeResolved klass);
 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1constantPool(JNIEnv *, jobject, jobject klass) {
+  TRACE_C1X_3("VMEntries::RiType_constantPool");
   VM_ENTRY_MARK;
 
   assert(JNIHandles::resolve(klass) != NULL, "");
@@ -360,6 +375,7 @@
 
 // public RiMethod RiType_resolveMethodImpl(HotSpotTypeResolved klass, String name, String signature);
 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_3resolveMethodImpl(JNIEnv *, jobject, jobject resolved_type, jstring name, jstring signature) {
+  TRACE_C1X_3("VMEntries::RiType_resolveMethodImpl");
   VM_ENTRY_MARK;
 
   assert(JNIHandles::resolve(resolved_type) != NULL, "");
@@ -379,6 +395,7 @@
 
 // public boolean RiType_isSubtypeOf(HotSpotTypeResolved klass, RiType other);
 JNIEXPORT jboolean JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_2isSubtypeOf(JNIEnv *, jobject, jobject klass, jobject jother) {
+  TRACE_C1X_3("VMEntries::RiType_isSubtypeOf");
   oop other = JNIHandles::resolve(jother);
   assert(other->is_a(HotSpotTypeResolved::klass()), "resolved hotspot type expected");
   assert(JNIHandles::resolve(klass) != NULL, "");
@@ -396,6 +413,7 @@
 
 // public RiType RiType_componentType(HotSpotResolvedType klass);
 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1componentType(JNIEnv *, jobject, jobject klass) {
+  TRACE_C1X_3("VMEntries::RiType_componentType");
   ciArrayKlass* array_klass;
   {
     VM_ENTRY_MARK;
@@ -411,20 +429,29 @@
 
 // public RiType RiType_superType(HotSpotResolvedType klass);
 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1superType(JNIEnv *, jobject, jobject klass) {
-  Thread* THREAD = Thread::current();
+  TRACE_C1X_3("VMEntries::RiType_superType");
+  VM_ENTRY_MARK;
   KlassHandle klass_handle(java_lang_Class::as_klassOop(HotSpotTypeResolved::javaMirror(klass)));
   ciInstanceKlass* k = NULL;
-  {
-    VM_ENTRY_MARK;
+
+  if (klass_handle->oop_is_array()) {
+    k = (ciInstanceKlass *) CURRENT_ENV->get_object(SystemDictionary::Object_klass());
+  } else {
+    guarantee(klass_handle->oop_is_instance(), "must be instance klass");  
     k = (ciInstanceKlass *) CURRENT_ENV->get_object(klass_handle());
-    if (k->super() == NULL) return NULL;
-    return JNIHandles::make_local(C1XCompiler::get_RiType(k->super(), klass_handle, THREAD));
+    k = k->super();
+  }
+
+  if (k != NULL) {
+    return JNIHandles::make_local(C1XCompiler::get_RiType(k, klass_handle, THREAD));
+  } else {
+    return NULL;
   }
 }
 
 // public RiType RiType_uniqueConcreteSubtype(HotSpotResolvedType klass);
 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1uniqueConcreteSubtype(JNIEnv *, jobject, jobject klass) {
-  
+  TRACE_C1X_3("VMEntries::RiType_uniqueConcreteSubtype");
   Thread* THREAD = Thread::current();
   KlassHandle klass_handle(java_lang_Class::as_klassOop(HotSpotTypeResolved::javaMirror(klass)));
   ciInstanceKlass* k = NULL;
@@ -449,6 +476,7 @@
 
 // public RiType RiType_arrayOf(HotSpotTypeResolved klass);
 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1arrayOf(JNIEnv *, jobject, jobject klass) {
+  TRACE_C1X_3("VMEntries::RiType_arrayOf");
   VM_ENTRY_MARK;
 
   KlassHandle klass_handle(java_lang_Class::as_klassOop(HotSpotTypeResolved::javaMirror(klass)));
@@ -459,6 +487,7 @@
 
 // public RiType getPrimitiveArrayType(CiKind kind);
 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_getPrimitiveArrayType(JNIEnv *env, jobject, jobject kind) {
+  TRACE_C1X_3("VMEntries::VMEntries_getPrimitiveArrayType");
   VM_ENTRY_MARK;
   BasicType type = C1XCompiler::kindToBasicType(CiKind::typeChar(kind));
   assert(type != T_OBJECT, "primitive type expecteds");
@@ -468,6 +497,7 @@
 
 // public RiType getType(Class<?> javaClass);
 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_getType(JNIEnv *env, jobject, jobject javaClass) {
+  TRACE_C1X_3("VMEntries::VMEntries_getType");
   VM_ENTRY_MARK;
   oop javaClassOop = JNIHandles::resolve(javaClass);
   if (javaClassOop == NULL) {