summaryrefslogtreecommitdiff
path: root/libjava/include
diff options
context:
space:
mode:
authorAlexandre Oliva <aoliva@redhat.com>2007-03-07 07:27:25 +0000
committerAlexandre Oliva <aoliva@gcc.gnu.org>2007-03-07 07:27:25 +0000
commit18fa3240db054b98ef9464cbcedb186d819217fd (patch)
tree65dc1e16680788d96a4fb13f1406c83419164f7c /libjava/include
parentdd77833100a12f219e7278685059dd82196c78f4 (diff)
downloadgcc-18fa3240db054b98ef9464cbcedb186d819217fd.tar.gz
ffi.h.in (ffi_closure_alloc, [...]): New.
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. From-SVN: r122652
Diffstat (limited to 'libjava/include')
-rw-r--r--libjava/include/execution.h49
-rw-r--r--libjava/include/java-interp.h5
-rw-r--r--libjava/include/jvm.h6
3 files changed, 52 insertions, 8 deletions
diff --git a/libjava/include/execution.h b/libjava/include/execution.h
index 279e9c1b872..eac6133c5b7 100644
--- a/libjava/include/execution.h
+++ b/libjava/include/execution.h
@@ -1,6 +1,6 @@
// execution.h - Execution engines. -*- c++ -*-
-/* Copyright (C) 2004, 2006 Free Software Foundation
+/* Copyright (C) 2004, 2006, 2007 Free Software Foundation
This file is part of libgcj.
@@ -29,6 +29,7 @@ struct _Jv_ExecutionEngine
_Jv_ResolvedMethod *(*resolve_method) (_Jv_Method *, jclass,
jboolean);
void (*post_miranda_hook) (jclass);
+ _Jv_ClosureList **(*get_closure_list) (jclass);
};
// This handles gcj-compiled code except that compiled with
@@ -77,6 +78,11 @@ struct _Jv_CompiledEngine : public _Jv_ExecutionEngine
// Not needed.
}
+ static _Jv_ClosureList **do_get_closure_list (jclass)
+ {
+ return NULL;
+ }
+
_Jv_CompiledEngine ()
{
unregister = do_unregister;
@@ -87,6 +93,7 @@ struct _Jv_CompiledEngine : public _Jv_ExecutionEngine
create_ncode = do_create_ncode;
resolve_method = do_resolve_method;
post_miranda_hook = do_post_miranda_hook;
+ get_closure_list = do_get_closure_list;
}
// These operators make it so we don't have to link in libstdc++.
@@ -105,6 +112,7 @@ class _Jv_IndirectCompiledClass
{
public:
void **field_initializers;
+ _Jv_ClosureList **closures;
};
// This handles gcj-compiled code compiled with -findirect-classes.
@@ -114,14 +122,32 @@ struct _Jv_IndirectCompiledEngine : public _Jv_CompiledEngine
{
allocate_static_fields = do_allocate_static_fields;
allocate_field_initializers = do_allocate_field_initializers;
+ get_closure_list = do_get_closure_list;
}
+ static _Jv_IndirectCompiledClass *get_aux_info (jclass klass)
+ {
+ _Jv_IndirectCompiledClass *aux =
+ (_Jv_IndirectCompiledClass*)klass->aux_info;
+ if (!aux)
+ {
+ aux = (_Jv_IndirectCompiledClass*)
+ _Jv_AllocRawObj (sizeof (_Jv_IndirectCompiledClass));
+ klass->aux_info = aux;
+ }
+
+ return aux;
+ }
+
static void do_allocate_field_initializers (jclass klass)
{
- _Jv_IndirectCompiledClass *aux
- = (_Jv_IndirectCompiledClass*)
- _Jv_AllocRawObj (sizeof (_Jv_IndirectCompiledClass));
- klass->aux_info = aux;
+ _Jv_IndirectCompiledClass *aux = get_aux_info (klass);
+ if (!aux)
+ {
+ aux = (_Jv_IndirectCompiledClass*)
+ _Jv_AllocRawObj (sizeof (_Jv_IndirectCompiledClass));
+ klass->aux_info = aux;
+ }
aux->field_initializers = (void **)_Jv_Malloc (klass->field_count
* sizeof (void*));
@@ -172,6 +198,16 @@ struct _Jv_IndirectCompiledEngine : public _Jv_CompiledEngine
}
_Jv_Free (aux->field_initializers);
}
+
+ static _Jv_ClosureList **do_get_closure_list (jclass klass)
+ {
+ _Jv_IndirectCompiledClass *aux = get_aux_info (klass);
+
+ if (!aux->closures)
+ aux->closures = _Jv_ClosureListFinalizer ();
+
+ return aux->closures;
+ }
};
@@ -203,6 +239,8 @@ class _Jv_InterpreterEngine : public _Jv_ExecutionEngine
static void do_post_miranda_hook (jclass);
+ static _Jv_ClosureList **do_get_closure_list (jclass klass);
+
_Jv_InterpreterEngine ()
{
unregister = do_unregister;
@@ -213,6 +251,7 @@ class _Jv_InterpreterEngine : public _Jv_ExecutionEngine
create_ncode = do_create_ncode;
resolve_method = do_resolve_method;
post_miranda_hook = do_post_miranda_hook;
+ get_closure_list = do_get_closure_list;
}
// These operators make it so we don't have to link in libstdc++.
diff --git a/libjava/include/java-interp.h b/libjava/include/java-interp.h
index e23baab9bb2..c294cc81896 100644
--- a/libjava/include/java-interp.h
+++ b/libjava/include/java-interp.h
@@ -202,7 +202,7 @@ class _Jv_InterpMethod : public _Jv_MethodBase
}
// return the method's invocation pointer (a stub).
- void *ncode ();
+ void *ncode (jclass);
void compile (const void * const *);
static void run_normal (ffi_cif*, void*, ffi_raw*, void*);
@@ -293,6 +293,7 @@ class _Jv_InterpClass
_Jv_MethodBase **interpreted_methods;
_Jv_ushort *field_initializers;
jstring source_file_name;
+ _Jv_ClosureList **closures;
friend class _Jv_ClassReader;
friend class _Jv_InterpMethod;
@@ -341,7 +342,7 @@ class _Jv_JNIMethod : public _Jv_MethodBase
// This function is used when making a JNI call from the interpreter.
static void call (ffi_cif *, void *, ffi_raw *, void *);
- void *ncode ();
+ void *ncode (jclass);
friend class _Jv_ClassReader;
friend class _Jv_InterpreterEngine;
diff --git a/libjava/include/jvm.h b/libjava/include/jvm.h
index 9a99a954b28..02974e8c7ea 100644
--- a/libjava/include/jvm.h
+++ b/libjava/include/jvm.h
@@ -288,7 +288,7 @@ private:
_Jv_Utf8Const *method_signature,
jclass *found_class,
bool check_perms = true);
- static void *create_error_method(_Jv_Utf8Const *);
+ static void *create_error_method(_Jv_Utf8Const *, jclass);
/* The least significant bit of the signature pointer in a symbol
table is set to 1 by the compiler if the reference is "special",
@@ -341,6 +341,10 @@ void *_Jv_AllocBytes (jsize size) __attribute__((__malloc__));
/* Allocate space for a new non-Java object, which does not have the usual
Java object header but may contain pointers to other GC'ed objects. */
void *_Jv_AllocRawObj (jsize size) __attribute__((__malloc__));
+/* Allocate a double-indirect pointer to a _Jv_ClosureList such that
+ the _Jv_ClosureList gets automatically finalized when it is no
+ longer reachable, not even by other finalizable objects. */
+_Jv_ClosureList **_Jv_ClosureListFinalizer (void) __attribute__((__malloc__));
/* Explicitly throw an out-of-memory exception. */
void _Jv_ThrowNoMemory() __attribute__((__noreturn__));
/* Allocate an object with a single pointer. The first word is reserved