Commit 3610e0d5 by Tom Tromey

[multiple changes]

2001-05-23  Tom Tromey  <tromey@redhat.com>

	* posix-threads.cc (_Jv_self_cache): Renamed from self_cache.
	* gcj/Makefile.in: Rebuilt.
	* gcj/Makefile.am (gcj_HEADERS): Added libgcj-config.h.
	* gcj/javaprims.h: Include gcj/libgcj-config.h.
	* gcj/libgcj-config.h.in: New file.
	* libgcj.spec.in (*jc1): Added @HASH_SYNC_SPEC@.
	* configure: Rebuilt.
	* configure.in: Enable hash synchronization by default on some
	platforms.
	(HASH_SYNC_SPEC): New subst.
	(AC_CONFIG_HEADER): Added gcj/libgcj-config.h.
	Correctly use `test -z' instead of `test -n' in a couple places.
	(JV_HASH_SYNCHRONIZATION): Use AC_DEFINE; don't add to
	LIBGCJ_CXXFLAGS.
	* configure.host (enable_java_net_default): Initialize.
	(enable_hash_synchronization_default): New variable.

2001-05-23  Hans Boehm <Hans_Boehm@hp.com>

	* boehm.cc (_Jv_MarkObj): Don't mark sync_info when hash
	synchronization in use.
	(_Jv_MarkArray): Likewise.
	(_Jv_AllocBytes): Don't check return result.
	(handle_out_of_memory): New function.
	(_Jv_InitGC): Set GC_oom_fn.
	(trace_one_vtable): New global.
	(_Jv_AllocTraceOne): New function.
	* configure.in: Added --enable-hash-synchronization.
	* defineclass.cc, prims.cc, resolve.cc, java/lang/natString.cc,
	java/net/natInetAddress.cc: Remove _Jv_AllocBytesChecked.
	* nogc.cc (_Jv_AllocObj): Throw out-of-memory.
	(_Jv_AllocArray): Likewise.
	(_Jv_AllocBytes): Likewise.
	(_Jv_AllocPtrFreeObject): New function.
	(_Jv_AllocTraceOne): Likewise.
	* posix-threads.cc (_Jv_ThreadRegister): Handle slow
	pthread_self().
	(self_cache): New global.
	(_Jv_ThreadSelf_out_of_line): New function.
	* prims.cc (_Jv_AllocBytesChecked): Removed.
	(_Jv_ThrowNoMemory): New function.
	(_Jv_AllocObject): Don't check for null return from allocator.
	(_Jv_NewObjectArray): Likewise.
	(_Jv_AllocPtrFreeObject): New function.
	(_Jv_NewPrimArray): Allocate pointer-free object if possible.
	* include/javaprims.h (_Jv_AllocPtrFreeObject): Declare.
	(_Jv_MonitorEnter, _Jv_MonitorExit): Don't return value.
	* include/boehm-gc.h (_Jv_AllocObj): Define.
	(_Jv_AllocPtrFreeObj): Define.
	* include/jvm.h (_Jv_AllocPtrFreeObj): Declare.
	(_Jv_ThrowNoMemory): Declare.
	(_Jv_AllocTraceOne): Declare.
	(_Jv_AllocBytesChecked): Removed.
	* include/posix-threads.h (_Jv_MutexInit, _Jv_MutexLock,
	_Jv_MutexUnlock): Handle LOCK_DEBUG.
	(_Jv_ThreadSelf): Handle case where system pthread_self() is
	slow.
	* java/lang/Class.h (Class): Declare _Jv_AllocPtrFreeObj as
	friend.
	* java/lang/Object.h (sync_info): Conditional upon presence of
	hash synchronization.
	* java/lang/natObject.cc: Much new code to handle thin locks and
	hash synchronization.
	* java/lang/natString.cc (_Jv_AllocString): Allocate pointer-free
	object if possible.

From-SVN: r42519
parent 865e0a83
2001-05-23 Tom Tromey <tromey@redhat.com>
* posix-threads.cc (_Jv_self_cache): Renamed from self_cache.
* gcj/Makefile.in: Rebuilt.
* gcj/Makefile.am (gcj_HEADERS): Added libgcj-config.h.
* gcj/javaprims.h: Include gcj/libgcj-config.h.
* gcj/libgcj-config.h.in: New file.
* libgcj.spec.in (*jc1): Added @HASH_SYNC_SPEC@.
* configure: Rebuilt.
* configure.in: Enable hash synchronization by default on some
platforms.
(HASH_SYNC_SPEC): New subst.
(AC_CONFIG_HEADER): Added gcj/libgcj-config.h.
Correctly use `test -z' instead of `test -n' in a couple places.
(JV_HASH_SYNCHRONIZATION): Use AC_DEFINE; don't add to
LIBGCJ_CXXFLAGS.
* configure.host (enable_java_net_default): Initialize.
(enable_hash_synchronization_default): New variable.
2001-05-23 Hans Boehm <Hans_Boehm@hp.com>
* boehm.cc (_Jv_MarkObj): Don't mark sync_info when hash
synchronization in use.
(_Jv_MarkArray): Likewise.
(_Jv_AllocBytes): Don't check return result.
(handle_out_of_memory): New function.
(_Jv_InitGC): Set GC_oom_fn.
(trace_one_vtable): New global.
(_Jv_AllocTraceOne): New function.
* configure.in: Added --enable-hash-synchronization.
* defineclass.cc, prims.cc, resolve.cc, java/lang/natString.cc,
java/net/natInetAddress.cc: Remove _Jv_AllocBytesChecked.
* nogc.cc (_Jv_AllocObj): Throw out-of-memory.
(_Jv_AllocArray): Likewise.
(_Jv_AllocBytes): Likewise.
(_Jv_AllocPtrFreeObject): New function.
(_Jv_AllocTraceOne): Likewise.
* posix-threads.cc (_Jv_ThreadRegister): Handle slow
pthread_self().
(self_cache): New global.
(_Jv_ThreadSelf_out_of_line): New function.
* prims.cc (_Jv_AllocBytesChecked): Removed.
(_Jv_ThrowNoMemory): New function.
(_Jv_AllocObject): Don't check for null return from allocator.
(_Jv_NewObjectArray): Likewise.
(_Jv_AllocPtrFreeObject): New function.
(_Jv_NewPrimArray): Allocate pointer-free object if possible.
* include/javaprims.h (_Jv_AllocPtrFreeObject): Declare.
(_Jv_MonitorEnter, _Jv_MonitorExit): Don't return value.
* include/boehm-gc.h (_Jv_AllocObj): Define.
(_Jv_AllocPtrFreeObj): Define.
* include/jvm.h (_Jv_AllocPtrFreeObj): Declare.
(_Jv_ThrowNoMemory): Declare.
(_Jv_AllocTraceOne): Declare.
(_Jv_AllocBytesChecked): Removed.
* include/posix-threads.h (_Jv_MutexInit, _Jv_MutexLock,
_Jv_MutexUnlock): Handle LOCK_DEBUG.
(_Jv_ThreadSelf): Handle case where system pthread_self() is
slow.
* java/lang/Class.h (Class): Declare _Jv_AllocPtrFreeObj as
friend.
* java/lang/Object.h (sync_info): Conditional upon presence of
hash synchronization.
* java/lang/natObject.cc: Much new code to handle thin locks and
hash synchronization.
* java/lang/natString.cc (_Jv_AllocString): Allocate pointer-free
object if possible.
2001-05-23 Joseph S. Myers <jsm28@cam.ac.uk> 2001-05-23 Joseph S. Myers <jsm28@cam.ac.uk>
* gij.cc (version): Update copyright year. * gij.cc (version): Update copyright year.
......
// boehm.cc - interface between libjava and Boehm GC. // boehm.cc - interface between libjava and Boehm GC.
/* Copyright (C) 1998, 1999, 2000 Free Software Foundation /* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation
This file is part of libgcj. This file is part of libgcj.
...@@ -97,10 +97,13 @@ _Jv_MarkObj (void *addr, void *msp, void *msl, void * /* env */) ...@@ -97,10 +97,13 @@ _Jv_MarkObj (void *addr, void *msp, void *msl, void * /* env */)
if (__builtin_expect (! dt || !(dt -> get_finalizer()), false)) if (__builtin_expect (! dt || !(dt -> get_finalizer()), false))
return mark_stack_ptr; return mark_stack_ptr;
jclass klass = dt->clas; jclass klass = dt->clas;
ptr_t p;
// Every object has a sync_info pointer. # ifndef JV_HASH_SYNCHRONIZATION
ptr_t p = (ptr_t) obj->sync_info; // Every object has a sync_info pointer.
MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, obj, o1label); p = (ptr_t) obj->sync_info;
MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, obj, o1label);
# endif
// Mark the object's class. // Mark the object's class.
p = (ptr_t) klass; p = (ptr_t) klass;
MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, obj, o2label); MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, obj, o2label);
...@@ -300,10 +303,13 @@ _Jv_MarkArray (void *addr, void *msp, void *msl, void * /*env*/) ...@@ -300,10 +303,13 @@ _Jv_MarkArray (void *addr, void *msp, void *msl, void * /*env*/)
if (__builtin_expect (! dt || !(dt -> get_finalizer()), false)) if (__builtin_expect (! dt || !(dt -> get_finalizer()), false))
return mark_stack_ptr; return mark_stack_ptr;
jclass klass = dt->clas; jclass klass = dt->clas;
ptr_t p;
// Every object has a sync_info pointer. # ifndef JV_HASH_SYNCHRONIZATION
ptr_t p = (ptr_t) array->sync_info; // Every object has a sync_info pointer.
MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, array, e1label); p = (ptr_t) array->sync_info;
MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, array, e1label);
# endif
// Mark the object's class. // Mark the object's class.
p = (ptr_t) klass; p = (ptr_t) klass;
MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, obj, o2label); MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, obj, o2label);
...@@ -326,18 +332,24 @@ _Jv_MarkArray (void *addr, void *msp, void *msl, void * /*env*/) ...@@ -326,18 +332,24 @@ _Jv_MarkArray (void *addr, void *msp, void *msl, void * /*env*/)
// knows this, so in that case everything else will break, too. // knows this, so in that case everything else will break, too.
#define GCJ_DEFAULT_DESCR GC_MAKE_PROC(GC_GCJ_RESERVED_MARK_PROC_INDEX,0) #define GCJ_DEFAULT_DESCR GC_MAKE_PROC(GC_GCJ_RESERVED_MARK_PROC_INDEX,0)
void * void *
_Jv_BuildGCDescr(jclass klass) _Jv_BuildGCDescr(jclass)
{ {
/* FIXME: We should really look at the class and build the descriptor. */ /* FIXME: We should really look at the class and build the descriptor. */
return (void *)(GCJ_DEFAULT_DESCR); return (void *)(GCJ_DEFAULT_DESCR);
} }
#endif #endif
// Allocate space for a new Java object. // Allocate some space that is known to be pointer-free.
void * void *
_Jv_AllocObj (jsize size, jclass klass) _Jv_AllocBytes (jsize size)
{ {
return GC_GCJ_MALLOC (size, klass->vtable); void *r = GC_MALLOC_ATOMIC (size);
// We have to explicitly zero memory here, as the GC doesn't
// guarantee that PTRFREE allocations are zeroed. Note that we
// don't have to do this for other allocation types because we set
// the `ok_init' flag in the type descriptor.
memset (r, 0, size);
return r;
} }
// Allocate space for a new Java array. // Allocate space for a new Java array.
...@@ -368,20 +380,6 @@ _Jv_AllocArray (jsize size, jclass klass) ...@@ -368,20 +380,6 @@ _Jv_AllocArray (jsize size, jclass klass)
return obj; return obj;
} }
// Allocate some space that is known to be pointer-free.
void *
_Jv_AllocBytes (jsize size)
{
void *r = GC_MALLOC_ATOMIC (size);
// We have to explicitly zero memory here, as the GC doesn't
// guarantee that PTRFREE allocations are zeroed. Note that we
// don't have to do this for other allocation types because we set
// the `ok_init' flag in the type descriptor.
if (__builtin_expect (r != NULL, !NULL))
memset (r, 0, size);
return r;
}
static void static void
call_finalizer (GC_PTR obj, GC_PTR client_data) call_finalizer (GC_PTR obj, GC_PTR client_data)
{ {
...@@ -462,6 +460,11 @@ _Jv_EnableGC (void) ...@@ -462,6 +460,11 @@ _Jv_EnableGC (void)
_Jv_MutexUnlock (&disable_gc_mutex); _Jv_MutexUnlock (&disable_gc_mutex);
} }
static void * handle_out_of_memory(size_t)
{
_Jv_ThrowNoMemory();
}
void void
_Jv_InitGC (void) _Jv_InitGC (void)
{ {
...@@ -484,6 +487,10 @@ _Jv_InitGC (void) ...@@ -484,6 +487,10 @@ _Jv_InitGC (void)
// stash in the class vtable. // stash in the class vtable.
GC_init_gcj_malloc (0, (void *) _Jv_MarkObj); GC_init_gcj_malloc (0, (void *) _Jv_MarkObj);
// Cause an out of memory error to be thrown from the allocators,
// instead of returning 0. This is cheaper than checking on allocation.
GC_oom_fn = handle_out_of_memory;
LOCK (); LOCK ();
GC_java_finalization = 1; GC_java_finalization = 1;
...@@ -511,6 +518,28 @@ _Jv_InitGC (void) ...@@ -511,6 +518,28 @@ _Jv_InitGC (void)
ENABLE_SIGNALS (); ENABLE_SIGNALS ();
} }
#ifdef JV_HASH_SYNCHRONIZATION
// Allocate an object with a fake vtable pointer, which causes only
// the first field (beyond the fake vtable pointer) to be traced.
// Eventually this should probably be generalized.
static _Jv_VTable trace_one_vtable = {
0, // class pointer
(void *)(2 * sizeof(void *)),
// descriptor; scan 2 words incl. vtable ptr.
// Least significant bits must be zero to
// identify this as a lenght descriptor
{0} // First method
};
void *
_Jv_AllocTraceOne (jsize size /* includes vtable slot */)
{
return GC_GCJ_MALLOC (size, &trace_one_vtable);
}
#endif /* JV_HASH_SYNCHRONIZATION */
#if 0 #if 0
void void
_Jv_InitGC (void) _Jv_InitGC (void)
......
...@@ -24,6 +24,8 @@ libgcj_cflags= ...@@ -24,6 +24,8 @@ libgcj_cflags=
libgcj_cxxflags= libgcj_cxxflags=
libgcj_javaflags= libgcj_javaflags=
libgcj_interpreter= libgcj_interpreter=
enable_java_net_default=yes
enable_hash_synchronization_default=no
case "${target_optspace}:${host}" in case "${target_optspace}:${host}" in
yes:*) yes:*)
...@@ -63,6 +65,7 @@ case "${host}" in ...@@ -63,6 +65,7 @@ case "${host}" in
libgcj_cxxflags="-D__NO_MATH_INLINES" libgcj_cxxflags="-D__NO_MATH_INLINES"
libgcj_cflags="-D__NO_MATH_INLINES" libgcj_cflags="-D__NO_MATH_INLINES"
DIVIDESPEC=-fno-use-divide-subroutine DIVIDESPEC=-fno-use-divide-subroutine
enable_hash_synchronization_default=yes
;; ;;
alpha*-*) alpha*-*)
libgcj_flags="${libgcj_flags} -mieee" libgcj_flags="${libgcj_flags} -mieee"
...@@ -76,6 +79,7 @@ case "${host}" in ...@@ -76,6 +79,7 @@ case "${host}" in
ia64-*) ia64-*)
libgcj_flags="${libgcj_flags} -funwind-tables" libgcj_flags="${libgcj_flags} -funwind-tables"
libgcj_interpreter=yes libgcj_interpreter=yes
enable_hash_synchronization_default=yes
;; ;;
esac esac
......
...@@ -16,7 +16,7 @@ AC_ARG_WITH(cross-host, ...@@ -16,7 +16,7 @@ AC_ARG_WITH(cross-host,
LIBGCJ_CONFIGURE(.) LIBGCJ_CONFIGURE(.)
AM_CONFIG_HEADER(include/config.h) AM_CONFIG_HEADER(include/config.h gcj/libgcj-config.h)
# Only use libltdl for native builds. # Only use libltdl for native builds.
if test -z "${with_cross_host}"; then if test -z "${with_cross_host}"; then
...@@ -57,13 +57,32 @@ AC_ARG_ENABLE(getenv-properties, ...@@ -57,13 +57,32 @@ AC_ARG_ENABLE(getenv-properties,
don't set system properties from GCJ_PROPERTIES]) don't set system properties from GCJ_PROPERTIES])
dnl Whether GCJ_PROPERTIES is used depends on the target. dnl Whether GCJ_PROPERTIES is used depends on the target.
if test -n "$enable_getenv_properties"; then if test -z "$enable_getenv_properties"; then
enable_getenv_properties=${enable_getenv_properties_default-yes} enable_getenv_properties=${enable_getenv_properties_default-yes}
fi fi
if test "$enable_getenv_properties" = no; then if test "$enable_getenv_properties" = no; then
AC_DEFINE(DISABLE_GETENV_PROPERTIES) AC_DEFINE(DISABLE_GETENV_PROPERTIES)
fi fi
dnl Should we use hashtable-based synchronization?
dnl Currently works only for Linux X86/ia64
dnl Typically faster and more space-efficient
AC_ARG_ENABLE(hash-synchronization,
[ --enable-hash-synchronization
Use global hash table for monitor locks])
if test -z "$enable_hash_synchronization"; then
enable_hash_synchronization=$enable_hash_synchronization_default
fi
HASH_SYNC_SPEC=
if test "$enable_hash_synchronization" = yes; then
HASH_SYNC_SPEC=-fhash-synchronization
AC_DEFINE(JV_HASH_SYNCHRONIZATION)
fi
AC_SUBST(HASH_SYNC_SPEC)
dnl See if the user has requested runtime debugging. dnl See if the user has requested runtime debugging.
LIBGCJDEBUG="false" LIBGCJDEBUG="false"
AC_SUBST(LIBGCJDEBUG) AC_SUBST(LIBGCJDEBUG)
...@@ -150,7 +169,7 @@ AC_ARG_ENABLE(java-net, ...@@ -150,7 +169,7 @@ AC_ARG_ENABLE(java-net,
[ --disable-java-net disable java.net]) [ --disable-java-net disable java.net])
dnl Whether java.net is built by default can depend on the target. dnl Whether java.net is built by default can depend on the target.
if test -n "$enable_java_net"; then if test -z "$enable_java_net"; then
enable_java_net=${enable_java_net_default-yes} enable_java_net=${enable_java_net_default-yes}
fi fi
if test "$enable_java_net" = no; then if test "$enable_java_net" = no; then
......
...@@ -360,8 +360,8 @@ _Jv_ClassReader::parse () ...@@ -360,8 +360,8 @@ _Jv_ClassReader::parse ()
void _Jv_ClassReader::read_constpool () void _Jv_ClassReader::read_constpool ()
{ {
tags = (unsigned char*) _Jv_AllocBytesChecked (pool_count); tags = (unsigned char*) _Jv_AllocBytes (pool_count);
offsets = (unsigned int *) _Jv_AllocBytesChecked (sizeof (int) offsets = (unsigned int *) _Jv_AllocBytes (sizeof (int)
* pool_count) ; * pool_count) ;
/** first, we scan the constant pool, collecting tags and offsets */ /** first, we scan the constant pool, collecting tags and offsets */
...@@ -625,9 +625,9 @@ void _Jv_ClassReader::handleConstantPool () ...@@ -625,9 +625,9 @@ void _Jv_ClassReader::handleConstantPool ()
/** now, we actually define the class' constant pool */ /** now, we actually define the class' constant pool */
// the pool is scanned explicitly by the collector // the pool is scanned explicitly by the collector
jbyte *pool_tags = (jbyte*) _Jv_AllocBytesChecked (pool_count); jbyte *pool_tags = (jbyte*) _Jv_AllocBytes (pool_count);
_Jv_word *pool_data _Jv_word *pool_data
= (_Jv_word*) _Jv_AllocBytesChecked (pool_count * sizeof (_Jv_word)); = (_Jv_word*) _Jv_AllocBytes (pool_count * sizeof (_Jv_word));
def->constants.tags = pool_tags; def->constants.tags = pool_tags;
def->constants.data = pool_data; def->constants.data = pool_data;
...@@ -965,7 +965,7 @@ _Jv_ClassReader::checkExtends (jclass sub, jclass super) ...@@ -965,7 +965,7 @@ _Jv_ClassReader::checkExtends (jclass sub, jclass super)
void _Jv_ClassReader::handleInterfacesBegin (int count) void _Jv_ClassReader::handleInterfacesBegin (int count)
{ {
def->interfaces = (jclass*) _Jv_AllocBytesChecked (count*sizeof (jclass)); def->interfaces = (jclass*) _Jv_AllocBytes (count*sizeof (jclass));
def->interface_count = count; def->interface_count = count;
} }
...@@ -1032,10 +1032,10 @@ _Jv_ClassReader::checkImplements (jclass sub, jclass super) ...@@ -1032,10 +1032,10 @@ _Jv_ClassReader::checkImplements (jclass sub, jclass super)
void _Jv_ClassReader::handleFieldsBegin (int count) void _Jv_ClassReader::handleFieldsBegin (int count)
{ {
def->fields = (_Jv_Field*) def->fields = (_Jv_Field*)
_Jv_AllocBytesChecked (count * sizeof (_Jv_Field)); _Jv_AllocBytes (count * sizeof (_Jv_Field));
def->field_count = count; def->field_count = count;
def->field_initializers = (_Jv_ushort*) def->field_initializers = (_Jv_ushort*)
_Jv_AllocBytesChecked (count * sizeof (_Jv_ushort)); _Jv_AllocBytes (count * sizeof (_Jv_ushort));
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
def->field_initializers[i] = (_Jv_ushort) 0; def->field_initializers[i] = (_Jv_ushort) 0;
} }
...@@ -1172,11 +1172,11 @@ void ...@@ -1172,11 +1172,11 @@ void
_Jv_ClassReader::handleMethodsBegin (int count) _Jv_ClassReader::handleMethodsBegin (int count)
{ {
def->methods = (_Jv_Method*) def->methods = (_Jv_Method*)
_Jv_AllocBytesChecked (sizeof (_Jv_Method)*count); _Jv_AllocBytes (sizeof (_Jv_Method)*count);
def->interpreted_methods def->interpreted_methods
= (_Jv_MethodBase **) _Jv_AllocBytesChecked (sizeof (_Jv_MethodBase *) = (_Jv_MethodBase **) _Jv_AllocBytes (sizeof (_Jv_MethodBase *)
* count); * count);
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
def->interpreted_methods[i] = 0; def->interpreted_methods[i] = 0;
...@@ -1235,7 +1235,7 @@ void _Jv_ClassReader::handleCodeAttribute ...@@ -1235,7 +1235,7 @@ void _Jv_ClassReader::handleCodeAttribute
{ {
int size = _Jv_InterpMethod::size (exc_table_length, code_length); int size = _Jv_InterpMethod::size (exc_table_length, code_length);
_Jv_InterpMethod *method = _Jv_InterpMethod *method =
(_Jv_InterpMethod*) (_Jv_AllocBytesChecked (size)); (_Jv_InterpMethod*) (_Jv_AllocBytes (size));
method->max_stack = max_stack; method->max_stack = max_stack;
method->max_locals = max_locals; method->max_locals = max_locals;
...@@ -1282,7 +1282,7 @@ void _Jv_ClassReader::handleMethodsEnd () ...@@ -1282,7 +1282,7 @@ void _Jv_ClassReader::handleMethodsEnd ()
else else
{ {
_Jv_JNIMethod *m = (_Jv_JNIMethod *) _Jv_JNIMethod *m = (_Jv_JNIMethod *)
_Jv_AllocBytesChecked (sizeof (_Jv_JNIMethod)); _Jv_AllocBytes (sizeof (_Jv_JNIMethod));
m->defining_class = def; m->defining_class = def;
m->self = method; m->self = method;
m->function = NULL; m->function = NULL;
......
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
AUTOMAKE_OPTIONS = foreign AUTOMAKE_OPTIONS = foreign
gcjdir = $(includedir)/gcj gcjdir = $(includedir)/gcj
gcj_HEADERS = array.h cni.h field.h javaprims.h method.h gcj_HEADERS = array.h cni.h field.h javaprims.h method.h libgcj-config.h
...@@ -85,6 +85,7 @@ GCLIBS = @GCLIBS@ ...@@ -85,6 +85,7 @@ GCLIBS = @GCLIBS@
GCOBJS = @GCOBJS@ GCOBJS = @GCOBJS@
GCSPEC = @GCSPEC@ GCSPEC = @GCSPEC@
GCTESTSPEC = @GCTESTSPEC@ GCTESTSPEC = @GCTESTSPEC@
HASH_SYNC_SPEC = @HASH_SYNC_SPEC@
INCLTDL = @INCLTDL@ INCLTDL = @INCLTDL@
JC1GCSPEC = @JC1GCSPEC@ JC1GCSPEC = @JC1GCSPEC@
LIBDATASTARTSPEC = @LIBDATASTARTSPEC@ LIBDATASTARTSPEC = @LIBDATASTARTSPEC@
...@@ -123,13 +124,13 @@ libgcj_basedir = @libgcj_basedir@ ...@@ -123,13 +124,13 @@ libgcj_basedir = @libgcj_basedir@
AUTOMAKE_OPTIONS = foreign AUTOMAKE_OPTIONS = foreign
gcjdir = $(includedir)/gcj gcjdir = $(includedir)/gcj
gcj_HEADERS = array.h cni.h field.h javaprims.h method.h gcj_HEADERS = array.h cni.h field.h javaprims.h method.h libgcj-config.h
mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
CONFIG_HEADER = ../include/config.h CONFIG_HEADER = ../include/config.h libgcj-config.h
CONFIG_CLEAN_FILES = CONFIG_CLEAN_FILES =
HEADERS = $(gcj_HEADERS) HEADERS = $(gcj_HEADERS)
DIST_COMMON = Makefile.am Makefile.in DIST_COMMON = ./stamp-h2.in Makefile.am Makefile.in libgcj-config.h.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
...@@ -146,6 +147,34 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) ...@@ -146,6 +147,34 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
libgcj-config.h: stamp-h2
@if test ! -f $@; then \
rm -f stamp-h2; \
$(MAKE) stamp-h2; \
else :; fi
stamp-h2: $(srcdir)/libgcj-config.h.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES= CONFIG_HEADERS=gcj/libgcj-config.h \
$(SHELL) ./config.status
@echo timestamp > stamp-h2 2> /dev/null
$(srcdir)/libgcj-config.h.in: @MAINTAINER_MODE_TRUE@$(srcdir)/stamp-h2.in
@if test ! -f $@; then \
rm -f $(srcdir)/stamp-h2.in; \
$(MAKE) $(srcdir)/stamp-h2.in; \
else :; fi
$(srcdir)/stamp-h2.in: $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOHEADER)
@echo timestamp > $(srcdir)/stamp-h2.in 2> /dev/null
mostlyclean-hdr:
clean-hdr:
distclean-hdr:
-rm -f libgcj-config.h
maintainer-clean-hdr:
install-gcjHEADERS: $(gcj_HEADERS) install-gcjHEADERS: $(gcj_HEADERS)
@$(NORMAL_INSTALL) @$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(gcjdir) $(mkinstalldirs) $(DESTDIR)$(gcjdir)
...@@ -171,15 +200,15 @@ ID: $(HEADERS) $(SOURCES) $(LISP) ...@@ -171,15 +200,15 @@ ID: $(HEADERS) $(SOURCES) $(LISP)
here=`pwd` && cd $(srcdir) \ here=`pwd` && cd $(srcdir) \
&& mkid -f$$here/ID $$unique $(LISP) && mkid -f$$here/ID $$unique $(LISP)
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) TAGS: $(HEADERS) $(SOURCES) libgcj-config.h.in $(TAGS_DEPENDENCIES) $(LISP)
tags=; \ tags=; \
here=`pwd`; \ here=`pwd`; \
list='$(SOURCES) $(HEADERS)'; \ list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \ unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \ awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \ END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ test -z "$(ETAGS_ARGS)libgcj-config.h.in$$unique$(LISP)$$tags" \
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags libgcj-config.h.in $$unique $(LISP) -o $$here/TAGS)
mostlyclean-tags: mostlyclean-tags:
...@@ -218,6 +247,9 @@ check-am: all-am ...@@ -218,6 +247,9 @@ check-am: all-am
check: check-am check: check-am
installcheck-am: installcheck-am:
installcheck: installcheck-am installcheck: installcheck-am
all-recursive-am: libgcj-config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
install-exec-am: install-exec-am:
install-exec: install-exec-am install-exec: install-exec-am
...@@ -229,7 +261,7 @@ install-am: all-am ...@@ -229,7 +261,7 @@ install-am: all-am
install: install-am install: install-am
uninstall-am: uninstall-gcjHEADERS uninstall-am: uninstall-gcjHEADERS
uninstall: uninstall-am uninstall: uninstall-am
all-am: Makefile $(HEADERS) all-am: Makefile $(HEADERS) libgcj-config.h
all-redirect: all-am all-redirect: all-am
install-strip: install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
...@@ -246,31 +278,32 @@ distclean-generic: ...@@ -246,31 +278,32 @@ distclean-generic:
-rm -f config.cache config.log stamp-h stamp-h[0-9]* -rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic: maintainer-clean-generic:
mostlyclean-am: mostlyclean-tags mostlyclean-generic mostlyclean-am: mostlyclean-hdr mostlyclean-tags mostlyclean-generic
mostlyclean: mostlyclean-am mostlyclean: mostlyclean-am
clean-am: clean-tags clean-generic mostlyclean-am clean-am: clean-hdr clean-tags clean-generic mostlyclean-am
clean: clean-am clean: clean-am
distclean-am: distclean-tags distclean-generic clean-am distclean-am: distclean-hdr distclean-tags distclean-generic clean-am
-rm -f libtool -rm -f libtool
distclean: distclean-am distclean: distclean-am
maintainer-clean-am: maintainer-clean-tags maintainer-clean-generic \ maintainer-clean-am: maintainer-clean-hdr maintainer-clean-tags \
distclean-am maintainer-clean-generic distclean-am
@echo "This command is intended for maintainers to use;" @echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild." @echo "it deletes files that may require special tools to rebuild."
maintainer-clean: maintainer-clean-am maintainer-clean: maintainer-clean-am
.PHONY: uninstall-gcjHEADERS install-gcjHEADERS tags mostlyclean-tags \ .PHONY: mostlyclean-hdr distclean-hdr clean-hdr maintainer-clean-hdr \
uninstall-gcjHEADERS install-gcjHEADERS tags mostlyclean-tags \
distclean-tags clean-tags maintainer-clean-tags distdir info-am info \ distclean-tags clean-tags maintainer-clean-tags distdir info-am info \
dvi-am dvi check check-am installcheck-am installcheck install-exec-am \ dvi-am dvi check check-am installcheck-am installcheck all-recursive-am \
install-exec install-data-am install-data install-am install \ install-exec-am install-exec install-data-am install-data install-am \
uninstall-am uninstall all-redirect all-am all installdirs \ install uninstall-am uninstall all-redirect all-am all installdirs \
mostlyclean-generic distclean-generic clean-generic \ mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean maintainer-clean-generic clean mostlyclean distclean maintainer-clean
......
// javaprims.h - Main external header file for libgcj. -*- c++ -*- // javaprims.h - Main external header file for libgcj. -*- c++ -*-
/* Copyright (C) 1998, 1999, 2000 Free Software Foundation /* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation
This file is part of libgcj. This file is part of libgcj.
...@@ -14,6 +14,8 @@ details. */ ...@@ -14,6 +14,8 @@ details. */
// Force C++ compiler to use Java-style exceptions. // Force C++ compiler to use Java-style exceptions.
#pragma GCC java_exceptions #pragma GCC java_exceptions
#include <gcj/libgcj-config.h>
// FIXME: this is a hack until we get a proper gcjh. // FIXME: this is a hack until we get a proper gcjh.
// It is needed to work around system header files that define TRUE // It is needed to work around system header files that define TRUE
// and FALSE. // and FALSE.
...@@ -367,14 +369,24 @@ typedef struct _Jv_Field *jfieldID; ...@@ -367,14 +369,24 @@ typedef struct _Jv_Field *jfieldID;
typedef struct _Jv_Method *jmethodID; typedef struct _Jv_Method *jmethodID;
extern "C" jobject _Jv_AllocObject (jclass, jint) __attribute__((__malloc__)); extern "C" jobject _Jv_AllocObject (jclass, jint) __attribute__((__malloc__));
#ifdef JV_HASH_SYNCHRONIZATION
extern "C" jobject _Jv_AllocPtrFreeObject (jclass, jint)
__attribute__((__malloc__));
#else
// Collector still needs to scan sync_info
static inline jobject _Jv_AllocPtrFreeObject (jclass klass, jint sz)
{
return _Jv_AllocObject(klass, sz);
}
#endif
extern "C" jboolean _Jv_IsInstanceOf(jobject, jclass); extern "C" jboolean _Jv_IsInstanceOf(jobject, jclass);
extern "C" jstring _Jv_AllocString(jsize) __attribute__((__malloc__)); extern "C" jstring _Jv_AllocString(jsize) __attribute__((__malloc__));
extern "C" jstring _Jv_NewString (const jchar*, jsize) extern "C" jstring _Jv_NewString (const jchar*, jsize)
__attribute__((__malloc__)); __attribute__((__malloc__));
extern jint _Jv_FormatInt (jchar* bufend, jint num); extern jint _Jv_FormatInt (jchar* bufend, jint num);
extern "C" jchar* _Jv_GetStringChars (jstring str); extern "C" jchar* _Jv_GetStringChars (jstring str);
extern "C" jint _Jv_MonitorEnter (jobject); extern "C" void _Jv_MonitorEnter (jobject);
extern "C" jint _Jv_MonitorExit (jobject); extern "C" void _Jv_MonitorExit (jobject);
extern "C" jstring _Jv_NewStringLatin1(const char*, jsize) extern "C" jstring _Jv_NewStringLatin1(const char*, jsize)
__attribute__((__malloc__)); __attribute__((__malloc__));
extern "C" jsize _Jv_GetStringUTFLength (jstring); extern "C" jsize _Jv_GetStringUTFLength (jstring);
...@@ -400,4 +412,5 @@ struct _Jv_Utf8Const ...@@ -400,4 +412,5 @@ struct _Jv_Utf8Const
char data[1]; /* In Utf8 format, with final '\0'. */ char data[1]; /* In Utf8 format, with final '\0'. */
}; };
#endif /* __JAVAPRIMS_H__ */ #endif /* __JAVAPRIMS_H__ */
/* The header derived from this file is installed, so this file should
only contain defines which are named safely. */
/* Define if hash synchronization is in use. */
#undef JV_HASH_SYNCHRONIZATION
...@@ -85,6 +85,7 @@ GCLIBS = @GCLIBS@ ...@@ -85,6 +85,7 @@ GCLIBS = @GCLIBS@
GCOBJS = @GCOBJS@ GCOBJS = @GCOBJS@
GCSPEC = @GCSPEC@ GCSPEC = @GCSPEC@
GCTESTSPEC = @GCTESTSPEC@ GCTESTSPEC = @GCTESTSPEC@
HASH_SYNC_SPEC = @HASH_SYNC_SPEC@
INCLTDL = @INCLTDL@ INCLTDL = @INCLTDL@
JC1GCSPEC = @JC1GCSPEC@ JC1GCSPEC = @JC1GCSPEC@
LIBDATASTARTSPEC = @LIBDATASTARTSPEC@ LIBDATASTARTSPEC = @LIBDATASTARTSPEC@
...@@ -124,11 +125,11 @@ AUTOMAKE_OPTIONS = foreign ...@@ -124,11 +125,11 @@ AUTOMAKE_OPTIONS = foreign
include_HEADERS = jni.h jvmpi.h include_HEADERS = jni.h jvmpi.h
mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
CONFIG_HEADER = config.h CONFIG_HEADER = config.h ../gcj/libgcj-config.h
CONFIG_CLEAN_FILES = CONFIG_CLEAN_FILES =
HEADERS = $(include_HEADERS) HEADERS = $(include_HEADERS)
DIST_COMMON = ./stamp-h.in Makefile.am Makefile.in config.h.in DIST_COMMON = ./stamp-h1.in Makefile.am Makefile.in config.h.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
...@@ -145,24 +146,24 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) ...@@ -145,24 +146,24 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
config.h: stamp-h config.h: stamp-h1
@if test ! -f $@; then \ @if test ! -f $@; then \
rm -f stamp-h; \ rm -f stamp-h1; \
$(MAKE) stamp-h; \ $(MAKE) stamp-h1; \
else :; fi else :; fi
stamp-h: $(srcdir)/config.h.in $(top_builddir)/config.status stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
cd $(top_builddir) \ cd $(top_builddir) \
&& CONFIG_FILES= CONFIG_HEADERS=include/config.h \ && CONFIG_FILES= CONFIG_HEADERS=include/config.h \
$(SHELL) ./config.status $(SHELL) ./config.status
@echo timestamp > stamp-h 2> /dev/null @echo timestamp > stamp-h1 2> /dev/null
$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@$(srcdir)/stamp-h.in $(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@$(srcdir)/stamp-h1.in
@if test ! -f $@; then \ @if test ! -f $@; then \
rm -f $(srcdir)/stamp-h.in; \ rm -f $(srcdir)/stamp-h1.in; \
$(MAKE) $(srcdir)/stamp-h.in; \ $(MAKE) $(srcdir)/stamp-h1.in; \
else :; fi else :; fi
$(srcdir)/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) $(srcdir)/stamp-h1.in: $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOHEADER) cd $(top_srcdir) && $(AUTOHEADER)
@echo timestamp > $(srcdir)/stamp-h.in 2> /dev/null @echo timestamp > $(srcdir)/stamp-h1.in 2> /dev/null
mostlyclean-hdr: mostlyclean-hdr:
......
...@@ -21,4 +21,35 @@ extern "C" ...@@ -21,4 +21,35 @@ extern "C"
JV_MARKARRAY_DECL; JV_MARKARRAY_DECL;
}; };
// Enough stuff to inline _Jv_AllocObj. Ugly.
#include <gcj/javaprims.h>
#include <java/lang/Class.h>
#include <string.h>
extern "C" void * GC_gcj_malloc(size_t, void *);
extern "C" void * GC_malloc_atomic(size_t);
inline void *
_Jv_AllocObj (jsize size, jclass klass)
{
// This should call GC_GCJ_MALLOC, but that would involve
// including gc.h.
return GC_gcj_malloc (size, klass->vtable);
}
inline void *
_Jv_AllocPtrFreeObj (jsize size, jclass klass)
{
#ifdef JV_HASH_SYNCHRONIZATION
void * obj = GC_malloc_atomic(size);
*((_Jv_VTable **) obj) = klass->vtable;
#else
void * obj = GC_gcj_malloc(size, klass->vtable);
#endif
return obj;
}
// _Jv_AllocBytes (jsize size) should go here, too. But clients don't
// usually include this header.
#endif /* __JV_BOEHM_GC__ */ #endif /* __JV_BOEHM_GC__ */
...@@ -107,10 +107,18 @@ typedef void _Jv_FinalizerFunc (jobject); ...@@ -107,10 +107,18 @@ typedef void _Jv_FinalizerFunc (jobject);
/* Allocate space for a new Java object. */ /* Allocate space for a new Java object. */
void *_Jv_AllocObj (jsize size, jclass cl) __attribute__((__malloc__)); void *_Jv_AllocObj (jsize size, jclass cl) __attribute__((__malloc__));
/* Allocate space for a potentially uninitialized pointer-free object.
Interesting only with JV_HASH_SYNCHRONIZATION. */
void *_Jv_AllocPtrFreeObj (jsize size, jclass cl) __attribute__((__malloc__));
/* Allocate space for an array of Java objects. */ /* Allocate space for an array of Java objects. */
void *_Jv_AllocArray (jsize size, jclass cl) __attribute__((__malloc__)); void *_Jv_AllocArray (jsize size, jclass cl) __attribute__((__malloc__));
/* Allocate space that is known to be pointer-free. */ /* Allocate space that is known to be pointer-free. */
void *_Jv_AllocBytes (jsize size) __attribute__((__malloc__)); void *_Jv_AllocBytes (jsize size) __attribute__((__malloc__));
/* Explicitly throw an out-of-memory exception. */
void _Jv_ThrowNoMemory();
/* Allocate an object with a single pointer. The first word is reserved
for the GC, and the second word is the traced pointer. */
void *_Jv_AllocTraceOne (jsize size /* incl. reserved slot */);
/* Initialize the GC. */ /* Initialize the GC. */
void _Jv_InitGC (void); void _Jv_InitGC (void);
/* Register a finalizer. */ /* Register a finalizer. */
...@@ -157,9 +165,6 @@ void _Jv_SetInitialHeapSize (const char *arg); ...@@ -157,9 +165,6 @@ void _Jv_SetInitialHeapSize (const char *arg);
_Jv_GCSetMaximumHeapSize. */ _Jv_GCSetMaximumHeapSize. */
void _Jv_SetMaximumHeapSize (const char *arg); void _Jv_SetMaximumHeapSize (const char *arg);
/* Allocate some unscanned bytes. Throw exception if out of memory. */
void *_Jv_AllocBytesChecked (jsize size) __attribute__((__malloc__));
extern "C" void JvRunMain (jclass klass, int argc, const char **argv); extern "C" void JvRunMain (jclass klass, int argc, const char **argv);
void _Jv_RunMain (const char* name, int argc, const char **argv, bool is_jar); void _Jv_RunMain (const char* name, int argc, const char **argv, bool is_jar);
......
// -*- c++ -*- // -*- c++ -*-
// posix-threads.h - Defines for using POSIX threads. // posix-threads.h - Defines for using POSIX threads.
/* Copyright (C) 1998, 1999 Free Software Foundation /* Copyright (C) 1998, 1999, 2001 Free Software Foundation
This file is part of libgcj. This file is part of libgcj.
...@@ -106,10 +106,21 @@ _Jv_CondInit (_Jv_ConditionVariable_t *cv) ...@@ -106,10 +106,21 @@ _Jv_CondInit (_Jv_ConditionVariable_t *cv)
// Mutexes. // Mutexes.
// //
#ifdef LOCK_DEBUG
# include <stdio.h>
#endif
inline void inline void
_Jv_MutexInit (_Jv_Mutex_t *mu) _Jv_MutexInit (_Jv_Mutex_t *mu)
{ {
# ifdef LOCK_DEBUG /* Assumes Linuxthreads */
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
pthread_mutex_init (&mu->mutex, &attr);
# else
pthread_mutex_init (&mu->mutex, 0); pthread_mutex_init (&mu->mutex, 0);
# endif
mu->count = 0; mu->count = 0;
mu->owner = 0; mu->owner = 0;
...@@ -125,7 +136,16 @@ _Jv_MutexLock (_Jv_Mutex_t *mu) ...@@ -125,7 +136,16 @@ _Jv_MutexLock (_Jv_Mutex_t *mu)
} }
else else
{ {
pthread_mutex_lock (&mu->mutex); # ifdef LOCK_DEBUG
int result = pthread_mutex_lock (&mu->mutex);
if (0 != result)
{
fprintf(stderr, "Pthread_mutex_lock returned %d\n", result);
for (;;) {}
}
# else
pthread_mutex_lock (&mu->mutex);
# endif
mu->count = 1; mu->count = 1;
mu->owner = self; mu->owner = self;
} }
...@@ -136,14 +156,29 @@ inline int ...@@ -136,14 +156,29 @@ inline int
_Jv_MutexUnlock (_Jv_Mutex_t *mu) _Jv_MutexUnlock (_Jv_Mutex_t *mu)
{ {
if (_Jv_PthreadCheckMonitor (mu)) if (_Jv_PthreadCheckMonitor (mu))
return 1; {
# ifdef LOCK_DEBUG
fprintf(stderr, "_Jv_MutexUnlock: Not owner\n");
for (;;) {}
# endif
return 1;
}
mu->count--; mu->count--;
if (mu->count == 0) if (mu->count == 0)
{ {
mu->owner = 0; mu->owner = 0;
pthread_mutex_unlock (&mu->mutex); # ifdef LOCK_DEBUG
int result = pthread_mutex_unlock (&mu->mutex);
if (0 != result)
{
fprintf(stderr, "Pthread_mutex_unlock returned %d\n", result);
for (;;) {}
}
# else
pthread_mutex_unlock (&mu->mutex);
# endif
} }
return 0; return 0;
} }
...@@ -179,6 +214,126 @@ _Jv_ThreadCurrent (void) ...@@ -179,6 +214,126 @@ _Jv_ThreadCurrent (void)
return (java::lang::Thread *) pthread_getspecific (_Jv_ThreadKey); return (java::lang::Thread *) pthread_getspecific (_Jv_ThreadKey);
} }
#ifdef JV_HASH_SYNCHRONIZATION
// Should be specialized to just load the "current thread" register
// on platforms that support it. Speed is of the essence. The value
// of the descriptor is not, so long as there is a one-to-one correspondence
// to threads.
#ifdef __i386__
#define SLOW_PTHREAD_SELF
// Add a cache for pthread_self() if we don't have the thread
// pointer in a register.
#endif /* __i386__ */
#ifdef __ia64__
typedef size_t _Jv_ThreadId_t;
register size_t _Jv_self __asm__("r13");
// For linux_threads this is really a pointer to its thread data
// structure. We treat it as opaque. That should also work
// on other operating systems that follow the ABI standard.
// This should become the prototype for machines that maintain a thread
// pointer in a register.
inline _Jv_ThreadId_t
_Jv_ThreadSelf (void)
{
return _Jv_self;
}
#define JV_SELF_DEFINED
#endif /* __ia64__ */
#if defined(SLOW_PTHREAD_SELF)
typedef pthread_t _Jv_ThreadId_t;
// E.g. on X86 Linux, pthread_self() is too slow for our purpose.
// Instead we maintain a cache based on the current sp value.
// This is similar to what's done for thread local allocation in the
// GC, only far simpler.
// This code should probably go away when Linux/X86 starts using a
// segment register to hold the thread id.
# define LOG_THREAD_SPACING 12
// If two thread pointer values are closer than
// 1 << LOG_THREAD_SPACING, we assume they belong
// to the same thread.
# define SELF_CACHE_SIZE 1024
# define SC_INDEX(sp) (((unsigned long)(sp) >> 19) & (SELF_CACHE_SIZE-1))
// Mapping from sp value to cache index.
// Note that this is not in any real sense a hash
// function, since we need to be able to clear
// all possibly matching slots on thread startup.
// Thus all entries that might correspond to
// a given thread are intentionally contiguous.
// Works well with anything that allocates at least
// 512KB stacks.
# define SC_CLEAR_MIN (-16) // When starting a new thread, we clear
# define SC_CLEAR_MAX 0 // all self cache entries between
// SC_INDEX(sp)+SC_CLEAR_MIN and
// SC_INDEX(sp)+SC_CLEAR_MAX to ensure
// we never see stale values. The
// current values assume a downward
// growing stack of size <= 7.5 MB.
# define BAD_HIGH_SP_VALUE ((size_t)(-1))
extern volatile
struct self_cache_entry {
size_t high_sp_bits; // sp value >> LOG_THREAD_SPACING
pthread_t self; // Corresponding thread
} _Jv_self_cache[];
void _Jv_Self_Cache_Init();
_Jv_ThreadId_t
_Jv_ThreadSelf_out_of_line(volatile self_cache_entry *sce,
size_t high_sp_bits);
inline _Jv_ThreadId_t
_Jv_ThreadSelf (void)
{
int dummy;
size_t sp = (size_t)(&dummy);
unsigned h = SC_INDEX(sp);
volatile self_cache_entry *sce = _Jv_self_cache + h;
pthread_t candidate_self = sce -> self; // Read must precede following one.
// Read barrier goes here, if needed.
if (sce -> high_sp_bits == sp >> LOG_THREAD_SPACING)
{
// The sce -> self value we read must be valid. An intervening
// cache replacement by another thread would have first replaced
// high_sp_bits by something else, and it can't possibly change
// back without our intervention.
return candidate_self;
}
else
return _Jv_ThreadSelf_out_of_line(sce, sp >> LOG_THREAD_SPACING);
}
#define JV_SELF_DEFINED
#endif /* SLOW_PTHREAD_SELF */
#ifndef JV_SELF_DEFINED /* If all else fails, call pthread_self directly */
typedef pthread_t _Jv_ThreadId_t;
inline _Jv_ThreadId_t
_Jv_ThreadSelf (void)
{
return pthread_self();
}
#endif /* !JV_SELF_DEFINED */
#endif /* JV_HASH_SYNCHRONIZATION */
inline _Jv_Thread_t * inline _Jv_Thread_t *
_Jv_ThreadCurrentData (void) _Jv_ThreadCurrentData (void)
{ {
......
...@@ -267,6 +267,7 @@ private: ...@@ -267,6 +267,7 @@ private:
friend jobject _Jv_AllocObject (jclass, jint); friend jobject _Jv_AllocObject (jclass, jint);
friend void *_Jv_AllocObj (jint, jclass); friend void *_Jv_AllocObj (jint, jclass);
friend void *_Jv_AllocPtrFreeObj (jint, jclass);
friend void *_Jv_AllocArray (jint, jclass); friend void *_Jv_AllocArray (jint, jclass);
friend jobject _Jv_JNI_ToReflectedField (_Jv_JNIEnv *, jclass, jfieldID, friend jobject _Jv_JNI_ToReflectedField (_Jv_JNIEnv *, jclass, jfieldID,
......
...@@ -42,8 +42,8 @@ public: ...@@ -42,8 +42,8 @@ public:
void wait (void); void wait (void);
void wait (jlong timeout); void wait (jlong timeout);
friend jint _Jv_MonitorEnter (jobject obj); friend void _Jv_MonitorEnter (jobject obj);
friend jint _Jv_MonitorExit (jobject obj); friend void _Jv_MonitorExit (jobject obj);
friend void _Jv_InitializeSyncMutex (void); friend void _Jv_InitializeSyncMutex (void);
friend void _Jv_FinalizeObject (jobject obj); friend void _Jv_FinalizeObject (jobject obj);
...@@ -63,10 +63,12 @@ private: ...@@ -63,10 +63,12 @@ private:
// This does not actually refer to a Java object. Instead it is a // This does not actually refer to a Java object. Instead it is a
// placeholder for a piece of internal data (the synchronization // placeholder for a piece of internal data (the synchronization
// information). // information).
jobject sync_info; # ifndef JV_HASH_SYNCHRONIZATION
jobject sync_info;
# endif
// Initialize the sync_info field. // Initialize the sync_info field. Not called with JV_HASH_SYNCHRONIZATION.
void sync_init (void); void sync_init (void);
}; };
#endif /* __JAVA_LANG_OBJECT_H__ */ #endif /* __JAVA_LANG_OBJECT_H__ */
...@@ -121,8 +121,7 @@ java::lang::String::rehash() ...@@ -121,8 +121,7 @@ java::lang::String::rehash()
if (strhash == NULL) if (strhash == NULL)
{ {
strhash_size = 1024; strhash_size = 1024;
strhash = (jstring *) _Jv_AllocBytesChecked (strhash_size strhash = (jstring *) _Jv_AllocBytes (strhash_size * sizeof (jstring));
* sizeof (jstring));
memset (strhash, 0, strhash_size * sizeof (jstring)); memset (strhash, 0, strhash_size * sizeof (jstring));
} }
else else
...@@ -130,8 +129,7 @@ java::lang::String::rehash() ...@@ -130,8 +129,7 @@ java::lang::String::rehash()
int i = strhash_size; int i = strhash_size;
jstring* ptr = strhash + i; jstring* ptr = strhash + i;
int nsize = strhash_size * 2; int nsize = strhash_size * 2;
jstring *next = (jstring *) _Jv_AllocBytesChecked (nsize jstring *next = (jstring *) _Jv_AllocBytes (nsize * sizeof (jstring));
* sizeof (jstring));
memset (next, 0, nsize * sizeof (jstring)); memset (next, 0, nsize * sizeof (jstring));
while (--i >= 0) while (--i >= 0)
...@@ -392,8 +390,18 @@ _Jv_AllocString(jsize len) ...@@ -392,8 +390,18 @@ _Jv_AllocString(jsize len)
{ {
jsize sz = sizeof(java::lang::String) + len * sizeof(jchar); jsize sz = sizeof(java::lang::String) + len * sizeof(jchar);
jstring obj = (jstring) JvAllocObject(&StringClass, sz); // We assert that for strings allocated this way, the data field
// will always point to the object itself. Thus there is no reason
// for the garbage collector to scan any of it.
// Furthermore, we're about to overwrite the string data, so
// initialization of the object is not an issue.
#ifdef ENABLE_JVMPI
jstring obj = (jstring) _Jv_AllocPtrFreeObject(&StringClass, sz);
#else
// Class needs no initialization, and there is no finalizer, so
// we can go directly to the collector's allocator interface.
jstring obj = (jstring) _Jv_AllocPtrFreeObj(&StringClass, sz);
#endif
obj->data = obj; obj->data = obj;
obj->boffset = sizeof(java::lang::String); obj->boffset = sizeof(java::lang::String);
obj->count = len; obj->count = len;
......
...@@ -95,7 +95,7 @@ java::net::InetAddress::aton (jstring host) ...@@ -95,7 +95,7 @@ java::net::InetAddress::aton (jstring host)
if (len < 100) if (len < 100)
hostname = buf; hostname = buf;
else else
hostname = (char*) _Jv_AllocBytesChecked (len+1); hostname = (char*) _Jv_AllocBytes (len+1);
JvGetStringUTFRegion (host, 0, host->length(), hostname); JvGetStringUTFRegion (host, 0, host->length(), hostname);
buf[len] = '\0'; buf[len] = '\0';
char* bytes = NULL; char* bytes = NULL;
...@@ -180,7 +180,7 @@ java::net::InetAddress::lookup (jstring host, java::net::InetAddress* iaddr, ...@@ -180,7 +180,7 @@ java::net::InetAddress::lookup (jstring host, java::net::InetAddress* iaddr,
if (len < 100) if (len < 100)
hostname = buf; hostname = buf;
else else
hostname = (char*) _Jv_AllocBytesChecked (len+1); hostname = (char*) _Jv_AllocBytes (len+1);
JvGetStringUTFRegion (host, 0, host->length(), hostname); JvGetStringUTFRegion (host, 0, host->length(), hostname);
buf[len] = '\0'; buf[len] = '\0';
#ifdef HAVE_GETHOSTBYNAME_R #ifdef HAVE_GETHOSTBYNAME_R
...@@ -201,7 +201,7 @@ java::net::InetAddress::lookup (jstring host, java::net::InetAddress* iaddr, ...@@ -201,7 +201,7 @@ java::net::InetAddress::lookup (jstring host, java::net::InetAddress* iaddr,
if (! ok && herr == ERANGE) if (! ok && herr == ERANGE)
{ {
size_r *= 2; size_r *= 2;
buffer_r = (char *) _Jv_AllocBytesChecked (size_r); buffer_r = (char *) _Jv_AllocBytes (size_r);
} }
else else
#endif /* HAVE_STRUCT_HOSTENT_DATA */ #endif /* HAVE_STRUCT_HOSTENT_DATA */
...@@ -255,7 +255,7 @@ java::net::InetAddress::lookup (jstring host, java::net::InetAddress* iaddr, ...@@ -255,7 +255,7 @@ java::net::InetAddress::lookup (jstring host, java::net::InetAddress* iaddr,
if (! ok && herr == ERANGE) if (! ok && herr == ERANGE)
{ {
size_r *= 2; size_r *= 2;
buffer_r = (char *) _Jv_AllocBytesChecked (size_r); buffer_r = (char *) _Jv_AllocBytes (size_r);
} }
else else
#endif /* HAVE_STRUCT_HOSTENT_DATA */ #endif /* HAVE_STRUCT_HOSTENT_DATA */
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
%rename lib liborig %rename lib liborig
*lib: -lgcj -lm @GCSPEC@ @THREADSPEC@ @ZLIBSPEC@ @SYSTEMSPEC@ %(libgcc) %(liborig) *lib: -lgcj -lm @GCSPEC@ @THREADSPEC@ @ZLIBSPEC@ @SYSTEMSPEC@ %(libgcc) %(liborig)
*jc1: @DIVIDESPEC@ @JC1GCSPEC@ @EXCEPTIONSPEC@ *jc1: @HASH_SYNC_SPEC@ @DIVIDESPEC@ @JC1GCSPEC@ @EXCEPTIONSPEC@
# #
# On some systems we force in a data_start symbol so that the GC will work # On some systems we force in a data_start symbol so that the GC will work
......
// nogc.cc - Implement null garbage collector. // nogc.cc - Implement null garbage collector.
/* Copyright (C) 1998, 1999, 2000 Free Software Foundation /* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation
This file is part of libgcj. This file is part of libgcj.
...@@ -32,6 +32,17 @@ _Jv_AllocObj (jsize size, jclass klass) ...@@ -32,6 +32,17 @@ _Jv_AllocObj (jsize size, jclass klass)
{ {
total += size; total += size;
void *obj = calloc (size, 1); void *obj = calloc (size, 1);
if (!obj) _Jv_ThrowNoMemory();
*((_Jv_VTable **) obj) = klass->vtable;
return obj;
}
void *
_Jv_AllocPtrFreeObj (jsize size, jclass klass)
{
total += size;
ptr_t obj = malloc (size, 1);
if (!obj) _Jv_ThrowNoMemory();
*((_Jv_VTable **) obj) = klass->vtable; *((_Jv_VTable **) obj) = klass->vtable;
return obj; return obj;
} }
...@@ -41,6 +52,7 @@ _Jv_AllocArray (jsize size, jclass klass) ...@@ -41,6 +52,7 @@ _Jv_AllocArray (jsize size, jclass klass)
{ {
total += size; total += size;
void *obj = calloc (size, 1); void *obj = calloc (size, 1);
if (!obj) _Jv_ThrowNoMemory();
*((_Jv_VTable **) obj) = klass->vtable; *((_Jv_VTable **) obj) = klass->vtable;
return obj; return obj;
} }
...@@ -49,7 +61,9 @@ void * ...@@ -49,7 +61,9 @@ void *
_Jv_AllocBytes (jsize size) _Jv_AllocBytes (jsize size)
{ {
total += size; total += size;
return calloc (size, 1); ptr_t obj = calloc (size, 1);
if (!obj) _Jv_ThrowNoMemory();
return obj;
} }
void void
...@@ -111,3 +125,13 @@ void ...@@ -111,3 +125,13 @@ void
_Jv_InitGC (void) _Jv_InitGC (void)
{ {
} }
#ifdef JV_HASH_SYNCHRONIZATION
void *
_Jv_AllocTraceOne (jsize size /* includes vtable slot */)
{
ptr_t obj = calloc(size, 1);
if (!obj) _Jv_ThrowNoMemory();
return result;
}
#endif /* JV_HASH_SYNCHRONIZATION */
// posix-threads.cc - interface between libjava and POSIX threads. // posix-threads.cc - interface between libjava and POSIX threads.
/* Copyright (C) 1998, 1999, 2000 Free Software Foundation /* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation
This file is part of libgcj. This file is part of libgcj.
...@@ -336,6 +336,22 @@ _Jv_ThreadRegister (_Jv_Thread_t *data) ...@@ -336,6 +336,22 @@ _Jv_ThreadRegister (_Jv_Thread_t *data)
// is called. Since it may need to be accessed from the new thread, work // is called. Since it may need to be accessed from the new thread, work
// around the potential race here by explicitly setting it again. // around the potential race here by explicitly setting it again.
data->thread = pthread_self (); data->thread = pthread_self ();
# ifdef SLOW_PTHREAD_SELF
// Clear all self cache slots that might be needed by this thread.
int dummy;
int low_index = SC_INDEX(&dummy) + SC_CLEAR_MIN;
int high_index = SC_INDEX(&dummy) + SC_CLEAR_MAX;
for (int i = low_index; i <= high_index; ++i)
{
int current_index = i;
if (current_index < 0)
current_index += SELF_CACHE_SIZE;
if (current_index >= SELF_CACHE_SIZE)
current_index -= SELF_CACHE_SIZE;
_Jv_self_cache[current_index].high_sp_bits = BAD_HIGH_SP_VALUE;
}
# endif
} }
void void
...@@ -356,7 +372,7 @@ really_start (void *x) ...@@ -356,7 +372,7 @@ really_start (void *x)
_Jv_ThreadRegister (info->data); _Jv_ThreadRegister (info->data);
info->method (info->data->thread_obj); info->method (info->data->thread_obj);
if (! (info->data->flags & FLAG_DAEMON)) if (! (info->data->flags & FLAG_DAEMON))
{ {
pthread_mutex_lock (&daemon_mutex); pthread_mutex_lock (&daemon_mutex);
...@@ -365,7 +381,7 @@ really_start (void *x) ...@@ -365,7 +381,7 @@ really_start (void *x)
pthread_cond_signal (&daemon_cond); pthread_cond_signal (&daemon_cond);
pthread_mutex_unlock (&daemon_mutex); pthread_mutex_unlock (&daemon_mutex);
} }
return NULL; return NULL;
} }
...@@ -418,3 +434,23 @@ _Jv_ThreadWait (void) ...@@ -418,3 +434,23 @@ _Jv_ThreadWait (void)
pthread_cond_wait (&daemon_cond, &daemon_mutex); pthread_cond_wait (&daemon_cond, &daemon_mutex);
pthread_mutex_unlock (&daemon_mutex); pthread_mutex_unlock (&daemon_mutex);
} }
#if defined(SLOW_PTHREAD_SELF)
// Support for pthread_self() lookup cache.
volatile self_cache_entry _Jv_self_cache[SELF_CACHE_SIZE];
_Jv_ThreadId_t
_Jv_ThreadSelf_out_of_line(volatile self_cache_entry *sce, size_t high_sp_bits)
{
pthread_t self = pthread_self();
// The ordering between the following writes matters.
// On Alpha, we probably need a memory barrier in the middle.
sce -> high_sp_bits = high_sp_bits;
sce -> self = self;
return self;
}
#endif /* SLOW_PTHREAD_SELF */
...@@ -221,11 +221,11 @@ _Jv_strLengthUtf8(char* str, int len) ...@@ -221,11 +221,11 @@ _Jv_strLengthUtf8(char* str, int len)
ptr = (unsigned char*) str; ptr = (unsigned char*) str;
limit = ptr + len; limit = ptr + len;
str_length = 0; str_length = 0;
for (; ptr < limit; str_length++) { for (; ptr < limit; str_length++)
if (UTF8_GET (ptr, limit) < 0) { {
return (-1); if (UTF8_GET (ptr, limit) < 0)
return (-1);
} }
}
return (str_length); return (str_length);
} }
...@@ -271,7 +271,7 @@ _Jv_makeUtf8Const (jstring string) ...@@ -271,7 +271,7 @@ _Jv_makeUtf8Const (jstring string)
jint len = _Jv_GetStringUTFLength (string); jint len = _Jv_GetStringUTFLength (string);
Utf8Const* m = (Utf8Const*) Utf8Const* m = (Utf8Const*)
_Jv_AllocBytesChecked (sizeof(Utf8Const) + len + 1); _Jv_AllocBytes (sizeof(Utf8Const) + len + 1);
m->hash = hash; m->hash = hash;
m->length = len; m->length = len;
...@@ -331,14 +331,11 @@ _Jv_ThrowNullPointerException () ...@@ -331,14 +331,11 @@ _Jv_ThrowNullPointerException ()
throw new java::lang::NullPointerException; throw new java::lang::NullPointerException;
} }
// Allocate some unscanned memory and throw an exception if no memory. // Explicitly throw a no memory exception.
void * // The collector calls this when it encounters an out-of-memory condition.
_Jv_AllocBytesChecked (jsize size) void _Jv_ThrowNoMemory()
{ {
void *r = _Jv_AllocBytes (size); _Jv_Throw (no_memory);
if (! r)
throw no_memory;
return r;
} }
// Allocate a new object of class KLASS. SIZE is the size of the object // Allocate a new object of class KLASS. SIZE is the size of the object
...@@ -350,8 +347,6 @@ _Jv_AllocObject (jclass klass, jint size) ...@@ -350,8 +347,6 @@ _Jv_AllocObject (jclass klass, jint size)
_Jv_InitClass (klass); _Jv_InitClass (klass);
jobject obj = (jobject) _Jv_AllocObj (size, klass); jobject obj = (jobject) _Jv_AllocObj (size, klass);
if (__builtin_expect (! obj, false))
throw no_memory;
// If this class has inherited finalize from Object, then don't // If this class has inherited finalize from Object, then don't
// bother registering a finalizer. We know that finalize() is the // bother registering a finalizer. We know that finalize() is the
...@@ -379,6 +374,14 @@ _Jv_AllocObject (jclass klass, jint size) ...@@ -379,6 +374,14 @@ _Jv_AllocObject (jclass klass, jint size)
event.u.obj_alloc.size = size; event.u.obj_alloc.size = size;
event.u.obj_alloc.obj_id = (jobjectID) obj; event.u.obj_alloc.obj_id = (jobjectID) obj;
// FIXME: This doesn't look right for the Boehm GC. A GC may
// already be in progress. _Jv_DisableGC () doesn't wait for it.
// More importantly, I don't see the need for disabling GC, since we
// blatantly have a pointer to obj on our stack, ensuring that the
// object can't be collected. Even for a nonconservative collector,
// it appears to me that this must be true, since we are about to
// return obj. Isn't this whole approach way too intrusive for
// a useful profiling interface? - HB
_Jv_DisableGC (); _Jv_DisableGC ();
(*_Jv_JVMPI_Notify_OBJECT_ALLOC) (&event); (*_Jv_JVMPI_Notify_OBJECT_ALLOC) (&event);
_Jv_EnableGC (); _Jv_EnableGC ();
...@@ -388,6 +391,43 @@ _Jv_AllocObject (jclass klass, jint size) ...@@ -388,6 +391,43 @@ _Jv_AllocObject (jclass klass, jint size)
return obj; return obj;
} }
// A version of the above that assumes the object contains no pointers,
// and requires no finalization. This can't happen if we need pointers
// to locks.
#ifdef JV_HASH_SYNCHRONIZATION
jobject
_Jv_AllocPtrFreeObject (jclass klass, jint size)
{
_Jv_InitClass (klass);
jobject obj = (jobject) _Jv_AllocPtrFreeObj (size, klass);
#ifdef ENABLE_JVMPI
// Service JVMPI request.
if (__builtin_expect (_Jv_JVMPI_Notify_OBJECT_ALLOC != 0, false))
{
JVMPI_Event event;
event.event_type = JVMPI_EVENT_OBJECT_ALLOC;
event.env_id = NULL;
event.u.obj_alloc.arena_id = 0;
event.u.obj_alloc.class_id = (jobjectID) klass;
event.u.obj_alloc.is_array = 0;
event.u.obj_alloc.size = size;
event.u.obj_alloc.obj_id = (jobjectID) obj;
_Jv_DisableGC ();
(*_Jv_JVMPI_Notify_OBJECT_ALLOC) (&event);
_Jv_EnableGC ();
}
#endif
return obj;
}
#endif /* JV_HASH_SYNCHRONIZATION */
// Allocate a new array of Java objects. Each object is of type // Allocate a new array of Java objects. Each object is of type
// `elementClass'. `init' is used to initialize each slot in the // `elementClass'. `init' is used to initialize each slot in the
// array. // array.
...@@ -408,8 +448,6 @@ _Jv_NewObjectArray (jsize count, jclass elementClass, jobject init) ...@@ -408,8 +448,6 @@ _Jv_NewObjectArray (jsize count, jclass elementClass, jobject init)
jclass klass = _Jv_GetArrayClass (elementClass, 0); jclass klass = _Jv_GetArrayClass (elementClass, 0);
obj = (jobjectArray) _Jv_AllocArray (size, klass); obj = (jobjectArray) _Jv_AllocArray (size, klass);
if (__builtin_expect (! obj, false))
throw no_memory;
// Cast away const. // Cast away const.
jsize *lp = const_cast<jsize *> (&obj->length); jsize *lp = const_cast<jsize *> (&obj->length);
*lp = count; *lp = count;
...@@ -444,13 +482,19 @@ _Jv_NewPrimArray (jclass eltype, jint count) ...@@ -444,13 +482,19 @@ _Jv_NewPrimArray (jclass eltype, jint count)
jclass klass = _Jv_GetArrayClass (eltype, 0); jclass klass = _Jv_GetArrayClass (eltype, 0);
# ifdef JV_HASH_SYNCHRONIZATION
// Since the vtable is always statically allocated,
// these are completely pointerfree! Make sure the GC doesn't touch them.
__JArray *arr =
(__JArray*) _Jv_AllocPtrFreeObj (size + elsize * count, klass);
memset((char *)arr + size, 0, elsize * count);
# else
__JArray *arr = (__JArray*) _Jv_AllocObj (size + elsize * count, klass); __JArray *arr = (__JArray*) _Jv_AllocObj (size + elsize * count, klass);
if (__builtin_expect (! arr, false)) // Note that we assume we are given zeroed memory by the allocator.
throw no_memory; # endif
// Cast away const. // Cast away const.
jsize *lp = const_cast<jsize *> (&arr->length); jsize *lp = const_cast<jsize *> (&arr->length);
*lp = count; *lp = count;
// Note that we assume we are given zeroed memory by the allocator.
return arr; return arr;
} }
......
...@@ -583,7 +583,7 @@ _Jv_PrepareClass(jclass klass) ...@@ -583,7 +583,7 @@ _Jv_PrepareClass(jclass klass)
// allocate static memory // allocate static memory
if (static_size != 0) if (static_size != 0)
{ {
char *static_data = (char*)_Jv_AllocBytesChecked (static_size); char *static_data = (char*)_Jv_AllocBytes (static_size);
memset (static_data, 0, static_size); memset (static_data, 0, static_size);
...@@ -697,7 +697,7 @@ _Jv_PrepareClass(jclass klass) ...@@ -697,7 +697,7 @@ _Jv_PrepareClass(jclass klass)
/* allocate vtable structure */ /* allocate vtable structure */
_Jv_VTable *vtable = (_Jv_VTable*) _Jv_VTable *vtable = (_Jv_VTable*)
_Jv_AllocBytesChecked (sizeof (_Jv_VTable) _Jv_AllocBytes (sizeof (_Jv_VTable)
+ (sizeof (void*) * (vtable_count))); + (sizeof (void*) * (vtable_count)));
vtable->clas = clz; vtable->clas = clz;
vtable->gc_descr = _Jv_BuildGCDescr(clz); vtable->gc_descr = _Jv_BuildGCDescr(clz);
...@@ -1076,7 +1076,7 @@ _Jv_InterpMethod::ncode () ...@@ -1076,7 +1076,7 @@ _Jv_InterpMethod::ncode ()
int arg_count = count_arguments (self->signature, staticp); int arg_count = count_arguments (self->signature, staticp);
ncode_closure *closure = ncode_closure *closure =
(ncode_closure*)_Jv_AllocBytesChecked (sizeof (ncode_closure) (ncode_closure*)_Jv_AllocBytes (sizeof (ncode_closure)
+ arg_count * sizeof (ffi_type*)); + arg_count * sizeof (ffi_type*));
init_cif (self->signature, init_cif (self->signature,
...@@ -1126,8 +1126,8 @@ _Jv_JNIMethod::ncode () ...@@ -1126,8 +1126,8 @@ _Jv_JNIMethod::ncode ()
int arg_count = count_arguments (self->signature, staticp); int arg_count = count_arguments (self->signature, staticp);
ncode_closure *closure = ncode_closure *closure =
(ncode_closure*)_Jv_AllocBytesChecked (sizeof (ncode_closure) (ncode_closure*)_Jv_AllocBytes (sizeof (ncode_closure)
+ arg_count * sizeof (ffi_type*)); + arg_count * sizeof (ffi_type*));
ffi_type *rtype; ffi_type *rtype;
init_cif (self->signature, init_cif (self->signature,
...@@ -1187,8 +1187,8 @@ _Jv_BuildResolvedMethod (_Jv_Method* method, ...@@ -1187,8 +1187,8 @@ _Jv_BuildResolvedMethod (_Jv_Method* method,
int arg_count = count_arguments (method->signature, staticp); int arg_count = count_arguments (method->signature, staticp);
_Jv_ResolvedMethod* result = (_Jv_ResolvedMethod*) _Jv_ResolvedMethod* result = (_Jv_ResolvedMethod*)
_Jv_AllocBytesChecked (sizeof (_Jv_ResolvedMethod) _Jv_AllocBytes (sizeof (_Jv_ResolvedMethod)
+ arg_count*sizeof (ffi_type*)); + arg_count*sizeof (ffi_type*));
result->stack_item_count result->stack_item_count
= init_cif (method->signature, = init_cif (method->signature,
......
...@@ -85,6 +85,7 @@ GCLIBS = @GCLIBS@ ...@@ -85,6 +85,7 @@ GCLIBS = @GCLIBS@
GCOBJS = @GCOBJS@ GCOBJS = @GCOBJS@
GCSPEC = @GCSPEC@ GCSPEC = @GCSPEC@
GCTESTSPEC = @GCTESTSPEC@ GCTESTSPEC = @GCTESTSPEC@
HASH_SYNC_SPEC = @HASH_SYNC_SPEC@
INCLTDL = @INCLTDL@ INCLTDL = @INCLTDL@
JC1GCSPEC = @JC1GCSPEC@ JC1GCSPEC = @JC1GCSPEC@
LIBDATASTARTSPEC = @LIBDATASTARTSPEC@ LIBDATASTARTSPEC = @LIBDATASTARTSPEC@
...@@ -123,15 +124,19 @@ libgcj_basedir = @libgcj_basedir@ ...@@ -123,15 +124,19 @@ libgcj_basedir = @libgcj_basedir@
AUTOMAKE_OPTIONS = foreign dejagnu AUTOMAKE_OPTIONS = foreign dejagnu
# Setup the testing framework, if you have one # Setup the testing framework, if you have one
EXPECT = `if [ -f $(top_builddir)/../expect/expect ] ; then echo $(top_builddir)/../expect/expect ; else echo expect ; fi` EXPECT = `if [ -f $(top_builddir)/../expect/expect ] ; then \
echo $(top_builddir)/../expect/expect ; \
else echo expect ; fi`
RUNTEST = `if [ -f $(top_srcdir)/../dejagnu/runtest ] ; then echo $(top_srcdir)/../dejagnu/runtest ; else echo runtest; fi` RUNTEST = `if [ -f $(top_srcdir)/../dejagnu/runtest ] ; then \
echo $(top_srcdir)/../dejagnu/runtest ; \
else echo runtest; fi`
RUNTESTFLAGS = @AM_RUNTESTFLAGS@ RUNTESTFLAGS = @AM_RUNTESTFLAGS@
mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
CONFIG_HEADER = ../include/config.h CONFIG_HEADER = ../include/config.h ../gcj/libgcj-config.h
CONFIG_CLEAN_FILES = CONFIG_CLEAN_FILES =
DIST_COMMON = ChangeLog Makefile.am Makefile.in DIST_COMMON = ChangeLog Makefile.am Makefile.in
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment