Mercurial > hg > xemacs-beta
diff src/dumper.c @ 3263:d674024a8674
[xemacs-hg @ 2006-02-27 16:29:00 by crestani]
- Introduce a fancy asynchronous finalization strategy on C level.
- Merge the code conditioned on MC_ALLOC into the code conditioned on
NEW_GC.
- Remove the possibility to free objects manually outside garbage
collections when the new collector is enabled.
author | crestani |
---|---|
date | Mon, 27 Feb 2006 16:29:29 +0000 |
parents | 503174cac05a |
children | a4917b3c97cc |
line wrap: on
line diff
--- a/src/dumper.c Sun Feb 26 22:51:04 2006 +0000 +++ b/src/dumper.c Mon Feb 27 16:29:29 2006 +0000 @@ -237,7 +237,7 @@ static Rawbyte *pdump_rt_list = 0; -#ifndef MC_ALLOC +#ifndef NEW_GC void pdump_objects_unmark (void) { @@ -261,10 +261,10 @@ break; } } -#endif /* not MC_ALLOC */ - - -#ifdef MC_ALLOC +#endif /* not NEW_GC */ + + +#ifdef NEW_GC /* The structure of the dump file looks like this: 0 - header - dumped objects @@ -281,7 +281,7 @@ - root lisp object address/value couples with the count preceding the list */ -#else /* not MC_ALLOC */ +#else /* not NEW_GC */ /* The structure of the dump file looks like this: 0 - header - dumped objects @@ -296,7 +296,7 @@ - root lisp object address/value couples with the count preceding the list */ -#endif /* not MC_ALLOC */ +#endif /* not NEW_GC */ #define PDUMP_SIGNATURE "XEmacsDP" @@ -434,7 +434,7 @@ static void *pdump_buf; static FILE *pdump_out; -#ifdef MC_ALLOC +#ifdef NEW_GC /* PDUMP_HASHSIZE is a large prime. */ #define PDUMP_HASHSIZE 1000003 /* Nothing special about PDUMP_HASH_MULTIPLIER: arbitrary odd integer @@ -443,23 +443,23 @@ /* Nothing special about PDUMP_HASH_STEP: arbitrary integer for linear probing. */ #define PDUMP_HASH_STEP 574853 -#else /* not MC_ALLOC */ +#else /* not NEW_GC */ #define PDUMP_HASHSIZE 200001 -#endif /* not MC_ALLOC */ +#endif /* not NEW_GC */ static pdump_block_list_elt **pdump_hash; -#ifndef MC_ALLOC +#ifndef NEW_GC /* Since most pointers are eight bytes aligned, the >>3 allows for a better hash */ -#endif /* not MC_ALLOC */ +#endif /* not NEW_GC */ static int pdump_make_hash (const void *obj) { -#ifdef MC_ALLOC +#ifdef NEW_GC return ((unsigned long)(obj) * PDUMP_HASH_MULTIPLIER) % PDUMP_HASHSIZE; -#else /* not MC_ALLOC */ +#else /* not NEW_GC */ return ((unsigned long)(obj)>>3) % PDUMP_HASHSIZE; -#endif /* not MC_ALLOC */ +#endif /* not NEW_GC */ } /* Return the entry for an already-registered memory block at OBJ, @@ -524,7 +524,7 @@ } } -#ifdef MC_ALLOC +#ifdef NEW_GC typedef struct mc_addr_elt { const void *obj; @@ -587,7 +587,7 @@ pdump_mc_hash[pos].obj = obj; pdump_mc_hash[pos].addr = addr; } -#endif /* MC_ALLOC */ +#endif /* NEW_GC */ static pdump_block_list * pdump_get_block_list (const struct memory_description *desc) @@ -879,6 +879,11 @@ imp = LHEADER_IMPLEMENTATION (objh); if (imp->description +#ifdef NEW_GC + /* Objects with finalizers cannot be dumped with the new + allocator's asynchronous finalization strategy. */ + && !imp->finalizer +#endif /* not NEW_GC */ && RECORD_DUMPABLE (objh)) { pdump_bump_depth (); @@ -1200,7 +1205,7 @@ retry_fwrite (desc ? pdump_buf : elt->obj, size, count, pdump_out); } -#ifdef MC_ALLOC +#ifdef NEW_GC /* To be able to relocate during load time, more information about the dumped objects are needed: The count (for array-like data structures), the size of the object, and the location in the dumped @@ -1237,9 +1242,6 @@ if (pdump_object_table[i].align == align) for (elt = pdump_object_table[i].first; elt; elt = elt->next) { -#ifndef NEW_GC - assert (elt->count == 1); -#endif /* not NEW_GC */ f (elt, lrecord_implementations_table[i]->description); } } @@ -1300,9 +1302,7 @@ case XD_LONG: case XD_INT_RESET: break; -#ifdef NEW_GC case XD_LISP_OBJECT_BLOCK_PTR: -#endif /* NEW_GC */ case XD_OPAQUE_DATA_PTR: case XD_ASCII_STRING: case XD_BLOCK_PTR: @@ -1405,7 +1405,7 @@ } } } -#else /* not MC_ALLOC */ +#else /* not NEW_GC */ /* Relocate a single memory block at DATA, described by DESC, from its assumed load location to its actual one by adding DELTA to all pointers in the block. Does not recursively relocate any other memory blocks @@ -1539,7 +1539,7 @@ } } } -#endif /* not MC_ALLOC */ +#endif /* not NEW_GC */ static void pdump_allocate_offset (pdump_block_list_elt *elt, @@ -2160,7 +2160,7 @@ fseek (pdump_out, header.stab_offset, SEEK_SET); -#ifdef MC_ALLOC +#ifdef NEW_GC { EMACS_INT zero = 0; pdump_scan_lisp_objects_by_alignment (pdump_dump_mc_data); @@ -2168,17 +2168,17 @@ pdump_scan_non_lisp_objects_by_alignment (pdump_dump_mc_data); PDUMP_WRITE_ALIGNED (EMACS_INT, zero); } -#endif /* MC_ALLOC */ +#endif /* NEW_GC */ pdump_dump_cv_data_info (); pdump_dump_cv_ptr_info (); -#ifdef MC_ALLOC +#ifdef NEW_GC pdump_dump_rtables (); -#endif /* MC_ALLOC */ +#endif /* NEW_GC */ pdump_dump_root_block_ptrs (); pdump_dump_root_blocks (); -#ifndef MC_ALLOC +#ifndef NEW_GC pdump_dump_rtables (); -#endif /* not MC_ALLOC */ +#endif /* not NEW_GC */ pdump_dump_root_lisp_objects (); retry_fclose (pdump_out); @@ -2227,7 +2227,7 @@ delta = ((EMACS_INT) pdump_start) - header->reloc_address; p = pdump_start + header->stab_offset; -#ifdef MC_ALLOC +#ifdef NEW_GC pdump_mc_hash = xnew_array_and_zero (mc_addr_elt, PDUMP_HASHSIZE); /* Allocate space for each object individually. First the @@ -2251,10 +2251,8 @@ { if (elt_count <= 1) mc_addr = (Rawbyte *) mc_alloc (real_size); -#ifdef NEW_GC else mc_addr = (Rawbyte *) mc_alloc_array (size, elt_count); -#endif /* NEW_GC */ #ifdef ALLOC_TYPE_STATS inc_lrecord_stats (real_size, (const struct lrecord_header *) @@ -2274,7 +2272,7 @@ else if (!(--count)) break; } -#endif /* MC_ALLOC */ +#endif /* NEW_GC */ /* Get the cv_data array */ p = (Rawbyte *) ALIGN_PTR (p, pdump_cv_data_dump_info); @@ -2293,7 +2291,7 @@ pdump_loaded_cv_ptr[i].adr = 0; } -#ifdef MC_ALLOC +#ifdef NEW_GC /* Relocate the heap objects */ pdump_rt_list = p; count = 2; @@ -2314,18 +2312,18 @@ else if (!(--count)) break; } -#endif /* MC_ALLOC */ +#endif /* NEW_GC */ /* Put back the pdump_root_block_ptrs */ p = (Rawbyte *) ALIGN_PTR (p, pdump_static_pointer); for (i = 0; i < header->nb_root_block_ptrs; i++) { pdump_static_pointer ptr = PDUMP_READ (p, pdump_static_pointer); -#ifdef MC_ALLOC +#ifdef NEW_GC (* ptr.address) = (Rawbyte *) pdump_get_mc_addr (ptr.value); -#else /* not MC_ALLOC */ +#else /* not NEW_GC */ (* ptr.address) = ptr.value + delta; -#endif /* not MC_ALLOC */ +#endif /* not NEW_GC */ } /* Put back the pdump_root_blocks and relocate */ @@ -2334,15 +2332,15 @@ pdump_root_block info = PDUMP_READ_ALIGNED (p, pdump_root_block); memcpy ((void *) info.blockaddr, p, info.size); if (info.desc) -#ifdef MC_ALLOC +#ifdef NEW_GC pdump_reloc_one_mc ((void *) info.blockaddr, info.desc); -#else /* not MC_ALLOC */ +#else /* not NEW_GC */ pdump_reloc_one ((void *) info.blockaddr, delta, info.desc); -#endif /* not MC_ALLOC */ +#endif /* not NEW_GC */ p += info.size; } -#ifndef MC_ALLOC +#ifndef NEW_GC /* Relocate the heap objects */ pdump_rt_list = p; count = 2; @@ -2363,7 +2361,7 @@ else if (!(--count)) break; } -#endif /* not MC_ALLOC */ +#endif /* not NEW_GC */ /* Put the pdump_root_lisp_objects variables in place */ i = PDUMP_READ_ALIGNED (p, Elemcount); @@ -2373,12 +2371,12 @@ pdump_static_Lisp_Object obj = PDUMP_READ (p, pdump_static_Lisp_Object); if (POINTER_TYPE_P (XTYPE (obj.value))) -#ifdef MC_ALLOC +#ifdef NEW_GC obj.value = wrap_pointer_1 ((Rawbyte *) pdump_get_mc_addr (XPNTR (obj.value))); -#else /* not MC_ALLOC */ +#else /* not NEW_GC */ obj.value = wrap_pointer_1 ((Rawbyte *) XPNTR (obj.value) + delta); -#endif /* not MC_ALLOC */ +#endif /* not NEW_GC */ (* obj.address) = obj.value; } @@ -2402,9 +2400,9 @@ p += sizeof (Lisp_Object) * rt.count; } -#ifdef MC_ALLOC +#ifdef NEW_GC xfree (pdump_mc_hash, mc_addr_elt *); -#endif /* MC_ALLOC */ +#endif /* NEW_GC */ #ifdef NEW_GC allow_incremental_gc = allow_inc_gc; @@ -2748,9 +2746,9 @@ { pdump_load_finish (); in_pdump = 0; -#ifdef MC_ALLOC +#ifdef NEW_GC pdump_free (); -#endif /* MC_ALLOC */ +#endif /* NEW_GC */ return 1; } @@ -2761,9 +2759,9 @@ { pdump_load_finish (); in_pdump = 0; -#ifdef MC_ALLOC +#ifdef NEW_GC pdump_free (); -#endif /* MC_ALLOC */ +#endif /* NEW_GC */ return 1; } pdump_free ();