[multiple changes]

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.

From-SVN: r126622
This commit is contained in:
Andrew Haley 2007-07-13 14:07:16 +00:00 committed by Andrew Haley
parent 2b2271f8f0
commit 976731ee6e
13 changed files with 139 additions and 17 deletions

View 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> 2007-07-13 Roger Sayle <roger@eyesopen.com>
* java/lang/natPosixProcess.cc: Include <sys/time.h> before * java/lang/natPosixProcess.cc: Include <sys/time.h> before

View File

@ -82,6 +82,10 @@ case "${host}" in
enable_getenv_properties_default=no enable_getenv_properties_default=no
enable_main_args_default=no enable_main_args_default=no
;; ;;
arm*-linux-gnu)
libgcj_interpreter=yes
sysdeps_dir=arm
;;
mips-tx39-*|mipstx39-unknown-*) mips-tx39-*|mipstx39-unknown-*)
libgcj_flags="${libgcj_flags} -G 0" libgcj_flags="${libgcj_flags} -G 0"
LDFLAGS="$LDFLAGS -Tjmr3904dram.ld" LDFLAGS="$LDFLAGS -Tjmr3904dram.ld"

View File

@ -80,15 +80,22 @@ gnu::classpath::VMStackWalker::getClassLoader(::java::lang::Class *c)
gnu::classpath::VMStackWalker::getCallingClassLoader(void) gnu::classpath::VMStackWalker::getCallingClassLoader(void)
{ {
_Jv_InitClass (&::gnu::classpath::VMStackWalker::class$); _Jv_InitClass (&::gnu::classpath::VMStackWalker::class$);
return jclass klass = _Jv_StackTrace::GetStackWalkerCallingClass ();
_Jv_StackTrace::GetStackWalkerCallingClass ()->getClassLoaderInternal (); if (klass)
return klass->getClassLoaderInternal ();
else
return NULL;
} }
::java::lang::ClassLoader * ::java::lang::ClassLoader *
gnu::classpath::VMStackWalker::getCallingClassLoader(::gnu::gcj::RawData *pc) gnu::classpath::VMStackWalker::getCallingClassLoader(::gnu::gcj::RawData *pc)
{ {
_Jv_InitClass (&::gnu::classpath::VMStackWalker::class$); _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 * ::java::lang::ClassLoader *

View File

@ -49,9 +49,11 @@ friend class java::lang::Class;
class java/lang/reflect/Field class java/lang/reflect/Field
prepend jfieldID _Jv_FromReflectedField (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_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 jfieldID (::_Jv_FromReflectedField) (java::lang::reflect::Field *);
friend jobject (::_Jv_JNI_ToReflectedField) (_Jv_JNIEnv*, jclass, jfieldID, jboolean); friend jobject (::_Jv_JNI_ToReflectedField) (_Jv_JNIEnv*, jclass, jfieldID, jboolean);
friend class java::lang::Class; friend class java::lang::Class;
friend jobject (::_Jv_getFieldInternal) (java::lang::reflect::Field f, jclass c, jobject o);
class java/lang/reflect/Method class java/lang/reflect/Method
prepend jmethodID _Jv_FromReflectedMethod (java::lang::reflect::Method *); prepend jmethodID _Jv_FromReflectedMethod (java::lang::reflect::Method *);

View File

@ -12,6 +12,7 @@
jfieldID _Jv_FromReflectedField (java::lang::reflect::Field *); jfieldID _Jv_FromReflectedField (java::lang::reflect::Field *);
jobject _Jv_JNI_ToReflectedField (_Jv_JNIEnv*, jclass, jfieldID, jboolean); 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 class java::lang::reflect::Field : public ::java::lang::reflect::AccessibleObject
{ {
@ -91,6 +92,7 @@ public:
friend jfieldID (::_Jv_FromReflectedField) (java::lang::reflect::Field *); friend jfieldID (::_Jv_FromReflectedField) (java::lang::reflect::Field *);
friend jobject (::_Jv_JNI_ToReflectedField) (_Jv_JNIEnv*, jclass, jfieldID, jboolean); friend jobject (::_Jv_JNI_ToReflectedField) (_Jv_JNIEnv*, jclass, jfieldID, jboolean);
friend class java::lang::Class; friend class java::lang::Class;
friend jobject (::_Jv_getFieldInternal) (java::lang::reflect::Field *f, jclass c, jobject o);
}; };
#endif // __java_lang_reflect_Field__ #endif // __java_lang_reflect_Field__

View File

@ -74,11 +74,6 @@ static void*
getAddr (java::lang::reflect::Field* field, jclass caller, jobject obj, getAddr (java::lang::reflect::Field* field, jclass caller, jobject obj,
jboolean checkFinal) 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; using namespace java::lang::reflect;
jfieldID fld = _Jv_FromReflectedField (field); jfieldID fld = _Jv_FromReflectedField (field);
@ -97,7 +92,8 @@ getAddr (java::lang::reflect::Field* field, jclass caller, jobject obj,
// Check accessibility, if required. // Check accessibility, if required.
if (! (Modifier::isPublic (flags) || field->isAccessible())) 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)) if (! _Jv_CheckAccess (caller, field->getDeclaringClass(), flags))
throw new java::lang::IllegalAccessException; throw new java::lang::IllegalAccessException;
} }

View File

@ -299,6 +299,15 @@ unbox (jobject o, jclass klass, void *rvalue, FFI_TYPE type)
JvFail ("Bad ffi type in proxy"); 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 // run_proxy is the entry point for all proxy methods. It boxes up
// all the arguments and then invokes the invocation handler's invoke() // all the arguments and then invokes the invocation handler's invoke()
// method. Exceptions are caught and propagated. // 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 // difference. We'd still have to save the method array because
// ncode structs are not scanned by the gc. // ncode structs are not scanned by the gc.
Field *f = proxyClass->getDeclaredField (JvNewStringLatin1 ("m")); 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]; Method *meth = elements(methods)[self->method_index];
JArray<jclass> *parameter_types = meth->internalGetParameterTypes (); JArray<jclass> *parameter_types = meth->internalGetParameterTypes ();

View File

@ -2,6 +2,6 @@
# symbols in libgcj.so. # symbols in libgcj.so.
{ {
global: Jv*; _Jv_*; __gcj_personality_v0; _Z*; global: Jv*; _Jv_*; __gcj_personality_v0; __gcj_personality_sj0; _Z*;
local: *; local: *;
}; };

View File

@ -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

View File

@ -10,7 +10,7 @@ proc gcj_cni_compile_cxx_to_o {file {options {}}} {
set oname ${name}.o set oname ${name}.o
# Find the generated header. # 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. # Find libgcj headers.
lappend options "additional_flags=-I$srcdir/.." lappend options "additional_flags=-I$srcdir/.."

View File

@ -31,7 +31,7 @@ proc gcj_jni_compile_c_to_so {file {options {}}} {
lappend options "additional_flags=${so_flag} -fPIC" lappend options "additional_flags=${so_flag} -fPIC"
# Find the generated header. # 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. # Ensure that the generated header has correct prototypes.
set cfile [file rootname $file].c 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" lappend options "additional_flags=-I. -I.. -I$srcdir/$subdir"
# Find jni.h and jni_md.h. # 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 # Append C++ options
lappend options "additional_flags=$options_cxx" lappend options "additional_flags=$options_cxx"

View File

@ -47,7 +47,7 @@ proc gcj_jni_compile_c_to_so {file {options {}}} {
# Find jni.h and jni_md.h. # Find jni.h and jni_md.h.
lappend options "additional_flags=-I$srcdir/../include \ lappend options "additional_flags=-I$srcdir/../include \
-I$srcdir/../classpath/include" -I$srcdir/../classpath/include -fdollars-in-identifiers"
# Append C++ options # Append C++ options
lappend options "additional_flags=$options_cxx" lappend options "additional_flags=$options_cxx"

View File

@ -11,11 +11,11 @@ proc gcj_jvmti_compile_cxx_to_o {file {options {}}} {
set oname ${name}.o set oname ${name}.o
# Find the generated header. # Find the generated header.
lappend options "additional_flags=-g -I. -I.." lappend options "additional_flags=-g -I. -I.. -fdollars-in-identifiers"
# Find libgcj headers. # Find libgcj headers.
lappend options "additional_flags=-I$srcdir/.." lappend options "additional_flags=-I$srcdir/.."
# Find jvmti.h, jvmti_md.h, jvmti-int.h, jvm.h requirements # 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 \ set x [libjava_prune_warnings \
[target_compile $file $oname object $options]] [target_compile $file $oname object $options]]