From: Daniel B. <da...@us...> - 2003-09-02 00:08:54
|
Update of /cvsroot/sbcl/sbcl/src/runtime In directory sc8-pr-cvs1:/tmp/cvs-serv31629/src/runtime Modified Files: gencgc.c Log Message: 0.8.3.23 Exciting gencgc hacking: SB-SYS:WITH-PINNED-OBJECTS When passing Lisp objects to foreign code, it is important that GC doesn't change the object's address as the foreign code's pointers to it won't be updated. Traditionally this is done using WITHOUT-GCING, but that's not ideal in a threaded system where one thread may be doing a blocking alien call and other threads would like to continue as normal. So, instead we shove pointers to the important objects on the C stack where they will cause the pages pointed to to be pinned in place using preserve_pointers. Additionally we make a small change to gencgc to ensure that they _stay_ pinned in subsequent GCs On ports that use cheneygc we can't do this, so WITH-PINNED-OBJECTS is just an alias for WITHOUT-GCING. As these ports don't have threads anyway, that's not a major inconvenience. Small updates to doc/internals-notes/threading-specials, slightly larger updates to comments regarding ALLOCATION and PSEUDO-ATOMIC macros Documentation update to the FFI chapter Index: gencgc.c =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/runtime/gencgc.c,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- gencgc.c 25 Aug 2003 21:00:01 -0000 1.36 +++ gencgc.c 2 Sep 2003 00:08:16 -0000 1.37 @@ -2698,8 +2698,9 @@ gc_assert(page_table[page].allocated != FREE_PAGE); gc_assert(page_table[page].bytes_used != 0); - /* Skip if it's already write-protected or an unboxed page. */ + /* Skip if it's already write-protected, pinned, or unboxed */ if (page_table[page].write_protected + || page_table[page].dont_move || (page_table[page].allocated & UNBOXED_PAGE)) return (0); @@ -3595,6 +3596,7 @@ for (i = 0; i < last_free_page; i++) if ((page_table[i].allocated == BOXED_PAGE) && (page_table[i].bytes_used != 0) + && !page_table[i].dont_move && (page_table[i].gen == generation)) { void *page_start; @@ -3658,7 +3660,8 @@ /* Before any pointers are preserved, the dont_move flags on the * pages need to be cleared. */ for (i = 0; i < last_free_page; i++) - page_table[i].dont_move = 0; + if(page_table[i].gen==from_space) + page_table[i].dont_move = 0; /* Un-write-protect the old-space pages. This is essential for the * promoted pages as they may contain pointers into the old-space |