diff options
author | aoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-03-07 07:27:25 +0000 |
---|---|---|
committer | aoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-03-07 07:27:25 +0000 |
commit | f20fe604499aca5125597268deecab241fc55e95 (patch) | |
tree | 65dc1e16680788d96a4fb13f1406c83419164f7c /boehm-gc | |
parent | c3265eac57d6f81f6df0daec4e2c15bac37da6a8 (diff) | |
download | gcc-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 'boehm-gc')
-rw-r--r-- | boehm-gc/ChangeLog | 11 | ||||
-rw-r--r-- | boehm-gc/dbg_mlc.c | 41 | ||||
-rw-r--r-- | boehm-gc/finalize.c | 63 | ||||
-rw-r--r-- | boehm-gc/include/gc.h | 18 |
4 files changed, 129 insertions, 4 deletions
diff --git a/boehm-gc/ChangeLog b/boehm-gc/ChangeLog index cc495e18772..89cabf0e88a 100644 --- a/boehm-gc/ChangeLog +++ b/boehm-gc/ChangeLog @@ -1,3 +1,14 @@ +2007-03-07 Alexandre Oliva <aoliva@redhat.com> + + * 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. + 2007-03-01 Brooks Moses <brooks.moses@codesourcery.com> * Makefile.am: Add dummy install-pdf target. diff --git a/boehm-gc/dbg_mlc.c b/boehm-gc/dbg_mlc.c index aacbb7a1b63..061a6a537b7 100644 --- a/boehm-gc/dbg_mlc.c +++ b/boehm-gc/dbg_mlc.c @@ -3,6 +3,7 @@ * Copyright (c) 1991-1995 by Xerox Corporation. All rights reserved. * Copyright (c) 1997 by Silicon Graphics. All rights reserved. * Copyright (c) 1999-2004 Hewlett-Packard Development Company, L.P. + * Copyright (C) 2007 Free Software Foundation, Inc * * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. @@ -1118,8 +1119,8 @@ GC_PTR *ocd; if (0 == base) return; if ((ptr_t)obj - base != sizeof(oh)) { GC_err_printf1( - "GC_debug_register_finalizer_no_order called with non-base-pointer 0x%lx\n", - obj); + "GC_debug_register_finalizer_no_order called with non-base-pointer 0x%lx\n", + obj); } if (0 == fn) { GC_register_finalizer_no_order(base, 0, 0, &my_old_fn, &my_old_cd); @@ -1129,7 +1130,41 @@ GC_PTR *ocd; &my_old_cd); } store_old(obj, my_old_fn, (struct closure *)my_old_cd, ofn, ocd); - } +} + +# ifdef __STDC__ + void GC_debug_register_finalizer_unreachable + (GC_PTR obj, GC_finalization_proc fn, + GC_PTR cd, GC_finalization_proc *ofn, + GC_PTR *ocd) +# else + void GC_debug_register_finalizer_unreachable + (obj, fn, cd, ofn, ocd) + GC_PTR obj; + GC_finalization_proc fn; + GC_PTR cd; + GC_finalization_proc *ofn; + GC_PTR *ocd; +# endif +{ + GC_finalization_proc my_old_fn; + GC_PTR my_old_cd; + ptr_t base = GC_base(obj); + if (0 == base) return; + if ((ptr_t)obj - base != sizeof(oh)) { + GC_err_printf1( + "GC_debug_register_finalizer_unreachable called with non-base-pointer 0x%lx\n", + obj); + } + if (0 == fn) { + GC_register_finalizer_unreachable(base, 0, 0, &my_old_fn, &my_old_cd); + } else { + GC_register_finalizer_unreachable(base, GC_debug_invoke_finalizer, + GC_make_closure(fn,cd), &my_old_fn, + &my_old_cd); + } + store_old(obj, my_old_fn, (struct closure *)my_old_cd, ofn, ocd); +} # ifdef __STDC__ void GC_debug_register_finalizer_ignore_self diff --git a/boehm-gc/finalize.c b/boehm-gc/finalize.c index 893f825976f..484d421d1d6 100644 --- a/boehm-gc/finalize.c +++ b/boehm-gc/finalize.c @@ -2,6 +2,7 @@ * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers * Copyright (c) 1991-1996 by Xerox Corporation. All rights reserved. * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved. + * Copyright (C) 2007 Free Software Foundation, Inc * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. @@ -315,6 +316,14 @@ ptr_t p; { } +/* Possible finalization_marker procedures. Note that mark stack */ +/* overflow is handled by the caller, and is not a disaster. */ +GC_API void GC_unreachable_finalize_mark_proc(p) +ptr_t p; +{ + return GC_normal_finalize_mark_proc(p); +} + /* Register a finalization function. See gc.h for details. */ @@ -511,6 +520,23 @@ finalization_mark_proc * mp; ocd, GC_null_finalize_mark_proc); } +# if defined(__STDC__) + void GC_register_finalizer_unreachable(void * obj, + GC_finalization_proc fn, void * cd, + GC_finalization_proc *ofn, void ** ocd) +# else + void GC_register_finalizer_unreachable(obj, fn, cd, ofn, ocd) + GC_PTR obj; + GC_finalization_proc fn; + GC_PTR cd; + GC_finalization_proc * ofn; + GC_PTR * ocd; +# endif +{ + GC_register_finalizer_inner(obj, fn, cd, ofn, + ocd, GC_unreachable_finalize_mark_proc); +} + #ifndef NO_DEBUGGING void GC_dump_finalization() { @@ -638,9 +664,44 @@ void GC_finalize() if (curr_fo -> fo_mark_proc == GC_null_finalize_mark_proc) { GC_MARK_FO(real_ptr, GC_normal_finalize_mark_proc); } - GC_set_mark_bit(real_ptr); + if (curr_fo -> fo_mark_proc != GC_unreachable_finalize_mark_proc) { + GC_set_mark_bit(real_ptr); + } } } + + /* now revive finalize-when-unreachable objects reachable from + other finalizable objects */ + curr_fo = GC_finalize_now; + prev_fo = 0; + while (curr_fo != 0) { + next_fo = fo_next(curr_fo); + if (curr_fo -> fo_mark_proc == GC_unreachable_finalize_mark_proc) { + real_ptr = (ptr_t)curr_fo -> fo_hidden_base; + if (!GC_is_marked(real_ptr)) { + GC_set_mark_bit(real_ptr); + } else { + if (prev_fo == 0) + GC_finalize_now = next_fo; + else + fo_set_next(prev_fo, next_fo); + + curr_fo -> fo_hidden_base = + (word) HIDE_POINTER(curr_fo -> fo_hidden_base); + GC_words_finalized -= + ALIGNED_WORDS(curr_fo -> fo_object_size) + + ALIGNED_WORDS(sizeof(struct finalizable_object)); + + i = HASH2(real_ptr, log_fo_table_size); + fo_set_next (curr_fo, fo_head[i]); + GC_fo_entries++; + fo_head[i] = curr_fo; + curr_fo = prev_fo; + } + } + prev_fo = curr_fo; + curr_fo = next_fo; + } } /* Remove dangling disappearing links. */ diff --git a/boehm-gc/include/gc.h b/boehm-gc/include/gc.h index 52ee8056ec4..c6c553d8427 100644 --- a/boehm-gc/include/gc.h +++ b/boehm-gc/include/gc.h @@ -3,6 +3,7 @@ * Copyright (c) 1991-1995 by Xerox Corporation. All rights reserved. * Copyright 1996-1999 by Silicon Graphics. All rights reserved. * Copyright 1999 by Hewlett-Packard Company. All rights reserved. + * Copyright (C) 2007 Free Software Foundation, Inc * * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. @@ -602,6 +603,8 @@ GC_API GC_PTR GC_debug_realloc_replacement GC_debug_register_finalizer_ignore_self(p, f, d, of, od) # define GC_REGISTER_FINALIZER_NO_ORDER(p, f, d, of, od) \ GC_debug_register_finalizer_no_order(p, f, d, of, od) +# define GC_REGISTER_FINALIZER_UNREACHABLE(p, f, d, of, od) \ + GC_debug_register_finalizer_unreachable(p, f, d, of, od) # define GC_MALLOC_STUBBORN(sz) GC_debug_malloc_stubborn(sz, GC_EXTRAS); # define GC_CHANGE_STUBBORN(p) GC_debug_change_stubborn(p) # define GC_END_STUBBORN_CHANGE(p) GC_debug_end_stubborn_change(p) @@ -624,6 +627,8 @@ GC_API GC_PTR GC_debug_realloc_replacement GC_register_finalizer_ignore_self(p, f, d, of, od) # define GC_REGISTER_FINALIZER_NO_ORDER(p, f, d, of, od) \ GC_register_finalizer_no_order(p, f, d, of, od) +# define GC_REGISTER_FINALIZER_UNREACHABLE(p, f, d, of, od) \ + GC_register_finalizer_unreachable(p, f, d, of, od) # define GC_MALLOC_STUBBORN(sz) GC_malloc_stubborn(sz) # define GC_CHANGE_STUBBORN(p) GC_change_stubborn(p) # define GC_END_STUBBORN_CHANGE(p) GC_end_stubborn_change(p) @@ -716,6 +721,19 @@ GC_API void GC_debug_register_finalizer_no_order GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd, GC_finalization_proc *ofn, GC_PTR *ocd)); +/* This is a special finalizer that is useful when an object's */ +/* finalizer must be run when the object is known to be no */ +/* longer reachable, not even from other finalizable objects. */ +/* This can be used in combination with finalizer_no_order so */ +/* as to release resources that must not be released while an */ +/* object can still be brought back to life by other */ +/* finalizers. */ +GC_API void GC_register_finalizer_unreachable + GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd, + GC_finalization_proc *ofn, GC_PTR *ocd)); +GC_API void GC_debug_register_finalizer_unreachable + GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd, + GC_finalization_proc *ofn, GC_PTR *ocd)); /* The following routine may be used to break cycles between */ /* finalizable objects, thus causing cyclic finalizable */ |