ARM: enable interpreter, add locks code

Andrew Haley aph-gcc@littlepinkcloud.COM
Fri Jul 13 13:42:00 GMT 2007


A few more ARM bug fixes to get gcj working again.  Most of them are
pretty trivial:

In natVMStackWalker::getCallingClassLoader we weren't checking for
caller==null, so we segfaulted

We weren't passing -fdollars-in-identifiers to the C/C++ compilers
while testing.  This resulted in lotsa spurious errors.

natVMProxy was calling natField which was, in turn, doing a wholly
unnecessary backtrace.  I took that out, so proxies work even if
backtrace doesn't.

We weren't exporting the __gcj_personality_sj0 symbol from the libgcj
DSO, so nothing linked.

Andrew.


2007-07-13  Andrew Haley  <aph@redhat.com>

        * libgcj.ver: Add __gcj_personality_sj0.

        * testsuite/libjava.jvmti/jvmti-interp.exp: Likewise.
        * testsuite/libjava.jni/jni.exp: Use -fdollars-in-identifiers.
        * testsuite/libjava.jni/cni.exp: Use -fdollars-in-identifiers.
        * testsuite/libjava.jvmti/jvmti.exp (gcj_jvmti_compile_cxx_to_o): Likewise.

        * gnu/classpath/natVMStackWalker.cc (getCallingClassLoader): Check
        klass is non-null.
        * java/lang/reflect/natField.cc (getAddr): Call
        _Jv_StackTrace::GetCallingClass only if CALLER is non-null.
        * java/lang/reflect/natVMProxy.cc (run_proxy): Use
        _Jv_getFieldInternal to get field proxyClass.m.
        (_Jv_getFieldInternal): New function.

Index: libgcj.ver
===================================================================
--- libgcj.ver	(revision 126194)
+++ libgcj.ver	(working copy)
@@ -2,6 +2,6 @@
 # symbols in libgcj.so.
 
 {
-  global: Jv*; _Jv_*; __gcj_personality_v0; _Z*;
+  global: Jv*; _Jv_*; __gcj_personality_v0; __gcj_personality_sj0; _Z*;
   local: *;
 };
Index: testsuite/libjava.cni/cni.exp
===================================================================
--- testsuite/libjava.cni/cni.exp	(revision 126194)
+++ testsuite/libjava.cni/cni.exp	(working copy)
@@ -10,7 +10,7 @@
   set oname ${name}.o
 
   # Find the generated header.
-  lappend options "additional_flags=-I. -I.. -I$srcdir/$subdir"
+  lappend options "additional_flags=-I. -I.. -I$srcdir/$subdir -fdollars-in-identifiers"
   # Find libgcj headers.
   lappend options "additional_flags=-I$srcdir/.."
 
Index: testsuite/libjava.jvmti/jvmti-interp.exp
===================================================================
--- testsuite/libjava.jvmti/jvmti-interp.exp	(revision 126194)
+++ testsuite/libjava.jvmti/jvmti-interp.exp	(working copy)
@@ -47,7 +47,7 @@
 
   # Find jni.h and jni_md.h.
   lappend options "additional_flags=-I$srcdir/../include  \
-                   -I$srcdir/../classpath/include"
+                   -I$srcdir/../classpath/include -fdollars-in-identifiers"
 
   # Append C++ options
   lappend options "additional_flags=$options_cxx"
Index: testsuite/libjava.jvmti/jvmti.exp
===================================================================
--- testsuite/libjava.jvmti/jvmti.exp	(revision 126194)
+++ testsuite/libjava.jvmti/jvmti.exp	(working copy)
@@ -11,11 +11,11 @@
   set oname ${name}.o
 
   # Find the generated header.
-  lappend options "additional_flags=-g -I. -I.."
+  lappend options "additional_flags=-g -I. -I.. -fdollars-in-identifiers"
   # Find libgcj headers.
   lappend options "additional_flags=-I$srcdir/.."
   # Find jvmti.h, jvmti_md.h, jvmti-int.h, jvm.h requirements
-  lappend options "additional_flags=-I$srcdir/../include -I$srcdir/../classpath/include -I$objdir/../include -I$objdir/../../boehm-gc/include"
+  lappend options "additional_flags=-I$srcdir/../include -I$srcdir/../classpath/include -I$objdir/../include -I$objdir/../../boehm-gc/include "
 
   set x [libjava_prune_warnings \
 	   [target_compile $file $oname object $options]]
Index: testsuite/libjava.jni/jni.exp
===================================================================
--- testsuite/libjava.jni/jni.exp	(revision 126194)
+++ testsuite/libjava.jni/jni.exp	(working copy)
@@ -31,7 +31,7 @@
 
   lappend options "additional_flags=${so_flag} -fPIC"
   # Find the generated header.
-  lappend options "additional_flags=-I. -I.. -I$srcdir/$subdir"
+  lappend options "additional_flags=-I. -I.. -I$srcdir/$subdir -fdollars-in-identifiers"
 
   # Ensure that the generated header has correct prototypes.
   set cfile [file rootname $file].c
@@ -219,7 +219,7 @@
   lappend options "additional_flags=-I. -I.. -I$srcdir/$subdir"
 
   # Find jni.h and jni_md.h.
-  lappend options "additional_flags=-I$srcdir/../include -I$srcdir/../classpath/include"
+  lappend options "additional_flags=-I$srcdir/../include -I$srcdir/../classpath/include -fdollars-in-identifiers"
 
   # Append C++ options
   lappend options "additional_flags=$options_cxx"
Index: headers.txt
===================================================================
--- headers.txt	(revision 126194)
+++ headers.txt	(working copy)
@@ -49,9 +49,11 @@
 class java/lang/reflect/Field
 prepend jfieldID _Jv_FromReflectedField (java::lang::reflect::Field *);
 prepend jobject _Jv_JNI_ToReflectedField (_Jv_JNIEnv*, jclass, jfieldID, jboolean);
+prepend jobject _Jv_getFieldInternal (java::lang::reflect::Field f, jclass c, jobject o);
 friend jfieldID (::_Jv_FromReflectedField) (java::lang::reflect::Field *);
 friend jobject (::_Jv_JNI_ToReflectedField) (_Jv_JNIEnv*, jclass, jfieldID, jboolean);
 friend class java::lang::Class;
+friend jobject (::_Jv_getFieldInternal) (java::lang::reflect::Field f, jclass c, jobject o);
 
 class java/lang/reflect/Method
 prepend jmethodID _Jv_FromReflectedMethod (java::lang::reflect::Method *);
Index: gnu/classpath/natVMStackWalker.cc
===================================================================
--- gnu/classpath/natVMStackWalker.cc	(revision 126194)
+++ gnu/classpath/natVMStackWalker.cc	(working copy)
@@ -80,15 +80,22 @@
 gnu::classpath::VMStackWalker::getCallingClassLoader(void)
 {
   _Jv_InitClass (&::gnu::classpath::VMStackWalker::class$);
-  return
-    _Jv_StackTrace::GetStackWalkerCallingClass ()->getClassLoaderInternal ();
+  jclass klass = _Jv_StackTrace::GetStackWalkerCallingClass ();
+  if (klass)
+    return klass->getClassLoaderInternal ();
+  else
+    return NULL;
 }
 
 ::java::lang::ClassLoader *
 gnu::classpath::VMStackWalker::getCallingClassLoader(::gnu::gcj::RawData *pc)
 {
   _Jv_InitClass (&::gnu::classpath::VMStackWalker::class$);
-  return GET_CALLING_CLASS(pc)->getClassLoaderInternal ();
+  jclass klass = GET_CALLING_CLASS(pc);
+  if (klass)
+    return klass->getClassLoaderInternal ();
+  else
+    return NULL;
 }
 
 ::java::lang::ClassLoader *
Index: java/lang/reflect/natField.cc
===================================================================
--- java/lang/reflect/natField.cc	(revision 126194)
+++ java/lang/reflect/natField.cc	(working copy)
@@ -74,11 +74,6 @@
 getAddr (java::lang::reflect::Field* field, jclass caller, jobject obj,
          jboolean checkFinal)
 {
-  // FIXME: we know CALLER is NULL here.  At one point we planned to
-  // have the compiler insert the caller as a hidden argument in some
-  // calls.  However, we never implemented that, so we have to find
-  // the caller by hand instead.
-  
   using namespace java::lang::reflect;
   
   jfieldID fld = _Jv_FromReflectedField (field);
@@ -97,7 +92,8 @@
   // Check accessibility, if required.
   if (! (Modifier::isPublic (flags) || field->isAccessible()))
     {
-      caller = _Jv_StackTrace::GetCallingClass (&Field::class$);
+      if (! caller)
+	caller = _Jv_StackTrace::GetCallingClass (&Field::class$);
       if (! _Jv_CheckAccess (caller, field->getDeclaringClass(), flags))
 	throw new java::lang::IllegalAccessException;
     }
Index: java/lang/reflect/natVMProxy.cc
===================================================================
--- java/lang/reflect/natVMProxy.cc	(revision 126194)
+++ java/lang/reflect/natVMProxy.cc	(working copy)
@@ -299,6 +299,15 @@
     JvFail ("Bad ffi type in proxy");
 }
 
+// _Jv_getFieldInternal is declared as a friend of reflect.Field in
+// libjava/headers.txt.  This gives us a way to call the private
+// method Field.get (Class caller, Object obj).
+extern inline jobject
+_Jv_getFieldInternal (java::lang::reflect::Field *f, jclass c, jobject o)
+{
+  return f->get(c, o);
+}
+
 // run_proxy is the entry point for all proxy methods.  It boxes up
 // all the arguments and then invokes the invocation handler's invoke()
 // method.  Exceptions are caught and propagated.
@@ -340,7 +349,8 @@
   // difference.  We'd still have to save the method array because
   // ncode structs are not scanned by the gc.
   Field *f = proxyClass->getDeclaredField (JvNewStringLatin1 ("m"));
-  JArray<Method*> *methods = (JArray<Method*>*)f->get (NULL);
+  JArray<Method*> *methods 
+    = (JArray<Method*>*)_Jv_getFieldInternal (f, proxyClass, NULL);
   Method *meth = elements(methods)[self->method_index];
 
   JArray<jclass> *parameter_types = meth->internalGetParameterTypes ();



More information about the Java-patches mailing list