summaryrefslogtreecommitdiff
path: root/libjava/interpret.cc
diff options
context:
space:
mode:
authoraoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4>2007-03-07 07:27:25 +0000
committeraoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4>2007-03-07 07:27:25 +0000
commitf20fe604499aca5125597268deecab241fc55e95 (patch)
tree65dc1e16680788d96a4fb13f1406c83419164f7c /libjava/interpret.cc
parentc3265eac57d6f81f6df0daec4e2c15bac37da6a8 (diff)
downloadgcc-f20fe604499aca5125597268deecab241fc55e95.tar.gz
libffi/ChangeLog:
* include/ffi.h.in (ffi_closure_alloc, ffi_closure_free): New. (ffi_prep_closure_loc): New. (ffi_prep_raw_closure_loc): New. (ffi_prep_java_raw_closure_loc): New. * src/closures.c: New file. * src/dlmalloc.c [FFI_MMAP_EXEC_WRIT] (struct malloc_segment): Replace sflags with exec_offset. [FFI_MMAP_EXEC_WRIT] (mmap_exec_offset, add_segment_exec_offset, sub_segment_exec_offset): New macros. (get_segment_flags, set_segment_flags, check_segment_merge): New macros. (is_mmapped_segment, is_extern_segment): Use get_segment_flags. (add_segment, sys_alloc, create_mspace, create_mspace_with_base, destroy_mspace): Use new macros. (sys_alloc): Silence warning. * Makefile.am (libffi_la_SOURCES): Add src/closures.c. * Makefile.in: Rebuilt. * src/prep_cif [FFI_CLOSURES] (ffi_prep_closure): Implement in terms of ffi_prep_closure_loc. * src/raw_api.c (ffi_prep_raw_closure_loc): Renamed and adjusted from... (ffi_prep_raw_closure): ... this. Re-implement in terms of the renamed version. * src/java_raw_api (ffi_prep_java_raw_closure_loc): Renamed and adjusted from... (ffi_prep_java_raw_closure): ... this. Re-implement in terms of the renamed version. * src/alpha/ffi.c (ffi_prep_closure_loc): Renamed from (ffi_prep_closure): ... this. * src/pa/ffi.c: Likewise. * src/cris/ffi.c: Likewise. Adjust. * src/frv/ffi.c: Likewise. * src/ia64/ffi.c: Likewise. * src/mips/ffi.c: Likewise. * src/powerpc/ffi_darwin.c: Likewise. * src/s390/ffi.c: Likewise. * src/sh/ffi.c: Likewise. * src/sh64/ffi.c: Likewise. * src/sparc/ffi.c: Likewise. * src/x86/ffi64.c: Likewise. * src/x86/ffi.c: Likewise. (FFI_INIT_TRAMPOLINE): Adjust. (ffi_prep_raw_closure_loc): Renamed and adjusted from... (ffi_prep_raw_closure): ... this. * src/powerpc/ffi.c (ffi_prep_closure_loc): Renamed from (ffi_prep_closure): ... this. (flush_icache): Adjust. boehm-gc/ChangeLog: * include/gc.h (GC_REGISTER_FINALIZER_UNREACHABLE): New. (GC_register_finalizer_unreachable): Declare. (GC_debug_register_finalizer_unreachable): Declare. * finalize.c (GC_unreachable_finalize_mark_proc): New. (GC_register_finalizer_unreachable): New. (GC_finalize): Handle it. * dbg_mlc.c (GC_debug_register_finalizer_unreachable): New. (GC_debug_register_finalizer_no_order): Fix whitespace. libjava/ChangeLog: * include/jvm.h (_Jv_ClosureListFinalizer): New. (_Jv_Linker::create_error_method): Adjust. * boehm.cc (_Jv_ClosureListFinalizer): New. * nogc.cc (_Jv_ClosureListFinalizer): New. * java/lang/Class.h (class _Jv_ClosureList): New. (class java::lang::Class): Declare it as friend. * java/lang/natClass.cc (_Jv_ClosureList::releaseClosures): New. (_Jv_ClosureList::registerClousure): New. * include/execution.h (_Jv_ExecutionEngine): Add get_closure_list. (_Jv_CompiledEngine::do_get_closure_list): New. (_Jv_CompiledEngine::_Jv_CompiledEngine): Use it. (_Jv_IndirectCompiledClass): Add closures. (_Jv_IndirectCompiledEngine::get_aux_info): New. (_Jv_IndirectCompiledEngine::do_allocate_field_initializers): Use it. (_Jv_IndirectCompiledEngine::do_get_closure_list): New. (_Jv_IndirectCompiledEngine::_Jv_IndirectCompiledEngine): Use it. (_Jv_InterpreterEngine::do_get_closure_list): Declare. (_Jv_InterpreterEngine::_Jv_InterpreterEngine): Use it. * interpret.cc (FFI_PREP_RAW_CLOSURE): Use _loc variants. (node_closure): Add closure list. (_Jv_InterpMethod::ncode): Add jclass argument. Use ffi_closure_alloc and the separate code pointer. Register the closure for finalization. (_Jv_JNIMethod::ncode): Likewise. (_Jv_InterpreterEngine::do_create_ncode): Pass klass to ncode. (_Jv_InterpreterEngine::do_get_closure_list): New. * include/java-interp.h (_Jv_InterpMethod::ncode): Adjust. (_Jv_InterpClass): Add closures field. (_Jv_JNIMethod::ncode): Adjust. * defineclass.cc (_Jv_ClassReader::handleCodeAttribute): Adjust. (_Jv_ClassReader::handleMethodsEnd): Likewise. * link.cc (struct method_closure): Add closure list. (_Jv_Linker::create_error_method): Add jclass argument. Use ffi_closure_alloc and the separate code pointer. Register the closure for finalization. (_Jv_Linker::link_symbol_table): Remove outdated comment about sharing of otable and atable. Adjust. * java/lang/reflect/natVMProxy.cc (ncode_closure): Add closure list. (ncode): Add jclass argument. Use ffi_closure_alloc and the separate code pointer. Register the closure for finalization. (java::lang::reflect::VMProxy::generateProxyClass): Adjust. * testsuite/libjava.jar/TestClosureGC.java: New. * testsuite/libjava.jar/TestClosureGC.out: New. * testsuite/libjava.jar/TestClosureGC.xfail: New. * testsuite/libjava.jar/TestClosureGC.jar: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@122652 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/interpret.cc')
-rw-r--r--libjava/interpret.cc49
1 files changed, 35 insertions, 14 deletions
diff --git a/libjava/interpret.cc b/libjava/interpret.cc
index 79276258c3d..ac23b060240 100644
--- a/libjava/interpret.cc
+++ b/libjava/interpret.cc
@@ -1255,10 +1255,10 @@ _Jv_init_cif (_Jv_Utf8Const* signature,
}
#if FFI_NATIVE_RAW_API
-# define FFI_PREP_RAW_CLOSURE ffi_prep_raw_closure
+# define FFI_PREP_RAW_CLOSURE ffi_prep_raw_closure_loc
# define FFI_RAW_SIZE ffi_raw_size
#else
-# define FFI_PREP_RAW_CLOSURE ffi_prep_java_raw_closure
+# define FFI_PREP_RAW_CLOSURE ffi_prep_java_raw_closure_loc
# define FFI_RAW_SIZE ffi_java_raw_size
#endif
@@ -1269,6 +1269,7 @@ _Jv_init_cif (_Jv_Utf8Const* signature,
typedef struct {
ffi_raw_closure closure;
+ _Jv_ClosureList list;
ffi_cif cif;
ffi_type *arg_types[0];
} ncode_closure;
@@ -1276,7 +1277,7 @@ typedef struct {
typedef void (*ffi_closure_fun) (ffi_cif*,void*,ffi_raw*,void*);
void *
-_Jv_InterpMethod::ncode ()
+_Jv_InterpMethod::ncode (jclass klass)
{
using namespace java::lang::reflect;
@@ -1286,9 +1287,12 @@ _Jv_InterpMethod::ncode ()
jboolean staticp = (self->accflags & Modifier::STATIC) != 0;
int arg_count = _Jv_count_arguments (self->signature, staticp);
+ void *code;
ncode_closure *closure =
- (ncode_closure*)_Jv_AllocBytes (sizeof (ncode_closure)
- + arg_count * sizeof (ffi_type*));
+ (ncode_closure*)ffi_closure_alloc (sizeof (ncode_closure)
+ + arg_count * sizeof (ffi_type*),
+ &code);
+ closure->list.registerClosure (klass, closure);
_Jv_init_cif (self->signature,
arg_count,
@@ -1341,9 +1345,11 @@ _Jv_InterpMethod::ncode ()
FFI_PREP_RAW_CLOSURE (&closure->closure,
&closure->cif,
fun,
- (void*)this);
+ (void*)this,
+ code);
+
+ self->ncode = code;
- self->ncode = (void*)closure;
return self->ncode;
}
@@ -1540,7 +1546,7 @@ _Jv_InterpMethod::set_insn (jlong index, pc_t insn)
}
void *
-_Jv_JNIMethod::ncode ()
+_Jv_JNIMethod::ncode (jclass klass)
{
using namespace java::lang::reflect;
@@ -1550,9 +1556,12 @@ _Jv_JNIMethod::ncode ()
jboolean staticp = (self->accflags & Modifier::STATIC) != 0;
int arg_count = _Jv_count_arguments (self->signature, staticp);
+ void *code;
ncode_closure *closure =
- (ncode_closure*)_Jv_AllocBytes (sizeof (ncode_closure)
- + arg_count * sizeof (ffi_type*));
+ (ncode_closure*)ffi_closure_alloc (sizeof (ncode_closure)
+ + arg_count * sizeof (ffi_type*),
+ &code);
+ closure->list.registerClosure (klass, closure);
ffi_type *rtype;
_Jv_init_cif (self->signature,
@@ -1594,9 +1603,10 @@ _Jv_JNIMethod::ncode ()
FFI_PREP_RAW_CLOSURE (&closure->closure,
&closure->cif,
fun,
- (void*) this);
+ (void*) this,
+ code);
- self->ncode = (void *) closure;
+ self->ncode = code;
return self->ncode;
}
@@ -1657,16 +1667,27 @@ _Jv_InterpreterEngine::do_create_ncode (jclass klass)
// cases. Well, we can't, because we don't allocate these
// objects using `new', and thus they don't get a vtable.
_Jv_JNIMethod *jnim = reinterpret_cast<_Jv_JNIMethod *> (imeth);
- klass->methods[i].ncode = jnim->ncode ();
+ klass->methods[i].ncode = jnim->ncode (klass);
}
else if (imeth != 0) // it could be abstract
{
_Jv_InterpMethod *im = reinterpret_cast<_Jv_InterpMethod *> (imeth);
- klass->methods[i].ncode = im->ncode ();
+ klass->methods[i].ncode = im->ncode (klass);
}
}
}
+_Jv_ClosureList **
+_Jv_InterpreterEngine::do_get_closure_list (jclass klass)
+{
+ _Jv_InterpClass *iclass = (_Jv_InterpClass *) klass->aux_info;
+
+ if (!iclass->closures)
+ iclass->closures = _Jv_ClosureListFinalizer ();
+
+ return iclass->closures;
+}
+
void
_Jv_InterpreterEngine::do_allocate_static_fields (jclass klass,
int pointer_size,