2007-07-13 Andrew Haley <aph@redhat.com>
authoraph <aph@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 13 Jul 2007 14:07:16 +0000 (14:07 +0000)
committeraph <aph@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 13 Jul 2007 14:07:16 +0000 (14:07 +0000)
* 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.

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

* configure.host (arm*-linux-gnu): New.
* sysdep/arm/locks.h: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@126622 138bc75d-0d04-0410-961f-82ee72b054a4

13 files changed:
libjava/ChangeLog
libjava/configure.host
libjava/gnu/classpath/natVMStackWalker.cc
libjava/headers.txt
libjava/java/lang/reflect/Field.h
libjava/java/lang/reflect/natField.cc
libjava/java/lang/reflect/natVMProxy.cc
libjava/libgcj.ver
libjava/sysdep/arm/locks.h [new file with mode: 0644]
libjava/testsuite/libjava.cni/cni.exp
libjava/testsuite/libjava.jni/jni.exp
libjava/testsuite/libjava.jvmti/jvmti-interp.exp
libjava/testsuite/libjava.jvmti/jvmti.exp

index a51629f..bf8c193 100644 (file)
@@ -1,3 +1,25 @@
+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.
+
+2007-07-11  Andrew Haley  <aph@redhat.com>
+
+       * configure.host (arm*-linux-gnu): New.
+       * sysdep/arm/locks.h: New.
+
 2007-07-13  Roger Sayle  <roger@eyesopen.com>
 
        * java/lang/natPosixProcess.cc: Include <sys/time.h> before
index 3c15abc..c32e714 100644 (file)
@@ -82,6 +82,10 @@ case "${host}" in
        enable_getenv_properties_default=no
        enable_main_args_default=no
        ;;
+  arm*-linux-gnu)
+       libgcj_interpreter=yes
+       sysdeps_dir=arm
+       ;;
   mips-tx39-*|mipstx39-unknown-*)
        libgcj_flags="${libgcj_flags} -G 0"
        LDFLAGS="$LDFLAGS -Tjmr3904dram.ld"
index f7eb883..1b336ca 100644 (file)
@@ -80,15 +80,22 @@ gnu::classpath::VMStackWalker::getClassLoader(::java::lang::Class *c)
 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 aad3fdd..d28d409 100644 (file)
@@ -49,9 +49,11 @@ friend class java::lang::Class;
 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 3e39fb2..0af9565 100644 (file)
@@ -12,6 +12,7 @@
 
 jfieldID _Jv_FromReflectedField (java::lang::reflect::Field *);
 jobject _Jv_JNI_ToReflectedField (_Jv_JNIEnv*, jclass, jfieldID, jboolean);
+jobject _Jv_getFieldInternal (java::lang::reflect::Field *f, jclass c, jobject o);
 
 class java::lang::reflect::Field : public ::java::lang::reflect::AccessibleObject
 {
@@ -91,6 +92,7 @@ public:
   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);
 };
 
 #endif // __java_lang_reflect_Field__
index b107ab8..734f653 100644 (file)
@@ -74,11 +74,6 @@ static void*
 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 @@ getAddr (java::lang::reflect::Field* field, jclass caller, jobject obj,
   // 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 e5f8fbe..1d9a3c6 100644 (file)
@@ -299,6 +299,15 @@ unbox (jobject o, jclass klass, void *rvalue, FFI_TYPE type)
     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 @@ run_proxy (ffi_cif *cif,
   // 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 ();
index 344600c..d2d189b 100644 (file)
@@ -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: *;
 };
diff --git a/libjava/sysdep/arm/locks.h b/libjava/sysdep/arm/locks.h
new file mode 100644 (file)
index 0000000..1f7763d
--- /dev/null
@@ -0,0 +1,79 @@
+// locks.h - Thread synchronization primitives. ARM implementation.
+
+/* Copyright (C) 2007  Free Software Foundation
+
+   This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
+details.  */
+
+#ifndef __SYSDEP_LOCKS_H__
+#define __SYSDEP_LOCKS_H__
+
+typedef size_t obj_addr_t;     /* Integer type big enough for object   */
+                               /* address.                             */
+
+/* Atomic compare and exchange.  These sequences are not actually
+   atomic; there is a race if *ADDR != OLD_VAL and we are preempted
+   between the two swaps.  However, they are very close to atomic, and
+   are the best that a pre-ARMv6 implementation can do without
+   operating system support.  LinuxThreads has been using these
+   sequences for many years.  */
+
+inline static bool
+compare_and_swap(volatile obj_addr_t *addr,
+                obj_addr_t old_val,
+                obj_addr_t new_val)
+{
+  volatile obj_addr_t result, tmp;
+  __asm__ ("\n"
+          "0:  ldr     %[tmp],[%[addr]]\n"
+          "    cmp     %[tmp],%[old_val]\n"
+          "    movne   %[result],#0\n"
+          "    bne     1f\n"
+          "    swp     %[result],%[new_val],[%[addr]]\n"
+          "    cmp     %[tmp],%[result]\n"
+          "    swpne   %[tmp],%[result],[%[addr]]\n"
+          "    bne     0b\n"
+          "    mov     %[result],#1\n"
+          "1:"
+          : [result] "=&r" (result), [tmp] "=&r" (tmp)
+          : [addr] "r" (addr), [new_val] "r" (new_val), [old_val] "r" (old_val)
+          : "cc", "memory");
+
+  return result;
+}
+
+inline static void
+release_set(volatile obj_addr_t *addr, obj_addr_t new_val)
+{
+  __asm__ __volatile__("" : : : "memory");
+  *(addr) = new_val;
+}
+
+inline static bool
+compare_and_swap_release(volatile obj_addr_t *addr,
+                                                    obj_addr_t old,
+                                                    obj_addr_t new_val)
+{
+  return compare_and_swap(addr, old, new_val);
+}
+
+// Ensure that subsequent instructions do not execute on stale
+// data that was loaded from memory before the barrier.
+inline static void
+read_barrier()
+{
+  __asm__ __volatile__("" : : : "memory");
+}
+
+// Ensure that prior stores to memory are completed with respect to other
+// processors.
+inline static void
+write_barrier()
+{
+  __asm__ __volatile__("" : : : "memory");
+}
+
+#endif
index 61fee3b..aec16b9 100644 (file)
@@ -10,7 +10,7 @@ proc gcj_cni_compile_cxx_to_o {file {options {}}} {
   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 1fff2b2..ab22c23 100644 (file)
@@ -31,7 +31,7 @@ proc gcj_jni_compile_c_to_so {file {options {}}} {
 
   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 @@ proc gcj_jni_invocation_compile_c_to_binary {file {options {}}} {
   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 bf0662b..68b1fc8 100644 (file)
@@ -47,7 +47,7 @@ proc gcj_jni_compile_c_to_so {file {options {}}} {
 
   # 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 c69fd2b..578eeb1 100644 (file)
@@ -11,11 +11,11 @@ proc gcj_jvmti_compile_cxx_to_o {file {options {}}} {
   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]]