Mercurial > hg > xemacs-beta
comparison src/lrecord.h @ 3092:141c2920ea48
[xemacs-hg @ 2005-11-25 01:41:31 by crestani]
Incremental Garbage Collector
author | crestani |
---|---|
date | Fri, 25 Nov 2005 01:42:08 +0000 |
parents | d30cd499e445 |
children | ad2f4ae9895b |
comparison
equal
deleted
inserted
replaced
3091:c22d8984148c | 3092:141c2920ea48 |
---|---|
1 #define NEW_GC_REMOVE | |
2 | |
1 /* The "lrecord" structure (header of a compound lisp object). | 3 /* The "lrecord" structure (header of a compound lisp object). |
2 Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc. | 4 Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc. |
3 Copyright (C) 1996, 2001, 2002, 2004, 2005 Ben Wing. | 5 Copyright (C) 1996, 2001, 2002, 2004, 2005 Ben Wing. |
4 | 6 |
5 This file is part of XEmacs. | 7 This file is part of XEmacs. |
215 { | 217 { |
216 /* Symbol value magic types come first to make SYMBOL_VALUE_MAGIC_P fast. | 218 /* Symbol value magic types come first to make SYMBOL_VALUE_MAGIC_P fast. |
217 #### This should be replaced by a symbol_value_magic_p flag | 219 #### This should be replaced by a symbol_value_magic_p flag |
218 in the Lisp_Symbol lrecord_header. */ | 220 in the Lisp_Symbol lrecord_header. */ |
219 lrecord_type_symbol_value_forward, /* 0 */ | 221 lrecord_type_symbol_value_forward, /* 0 */ |
220 lrecord_type_symbol_value_varalias, /* 1 */ | 222 lrecord_type_symbol_value_varalias, |
221 lrecord_type_symbol_value_lisp_magic, /* 2 */ | 223 lrecord_type_symbol_value_lisp_magic, |
222 lrecord_type_symbol_value_buffer_local, /* 3 */ | 224 lrecord_type_symbol_value_buffer_local, |
223 lrecord_type_max_symbol_value_magic = lrecord_type_symbol_value_buffer_local, | 225 lrecord_type_max_symbol_value_magic = lrecord_type_symbol_value_buffer_local, |
224 lrecord_type_symbol, /* 4 */ | 226 lrecord_type_symbol, |
225 lrecord_type_subr, /* 5 */ | 227 lrecord_type_subr, |
226 lrecord_type_cons, /* 6 */ | 228 lrecord_type_cons, |
227 lrecord_type_vector, /* 7 */ | 229 lrecord_type_vector, |
228 lrecord_type_string, /* 8 */ | 230 lrecord_type_string, |
229 #ifndef MC_ALLOC | 231 #ifndef MC_ALLOC |
230 lrecord_type_lcrecord_list, | 232 lrecord_type_lcrecord_list, |
231 #endif /* not MC_ALLOC */ | 233 #endif /* not MC_ALLOC */ |
232 lrecord_type_compiled_function, /* 9 */ | 234 lrecord_type_compiled_function, |
233 lrecord_type_weak_list, /* 10 */ | 235 lrecord_type_weak_list, |
234 lrecord_type_bit_vector, /* 11 */ | 236 lrecord_type_bit_vector, |
235 lrecord_type_float, /* 12 */ | 237 lrecord_type_float, |
236 lrecord_type_hash_table, /* 13 */ | 238 lrecord_type_hash_table, |
237 lrecord_type_lstream, /* 14 */ | 239 lrecord_type_lstream, |
238 lrecord_type_process, /* 15 */ | 240 lrecord_type_process, |
239 lrecord_type_charset, /* 16 */ | 241 lrecord_type_charset, |
240 lrecord_type_coding_system, /* 17 */ | 242 lrecord_type_coding_system, |
241 lrecord_type_char_table, /* 18 */ | 243 lrecord_type_char_table, |
242 lrecord_type_char_table_entry, /* 19 */ | 244 lrecord_type_char_table_entry, |
243 lrecord_type_range_table, /* 20 */ | 245 lrecord_type_range_table, |
244 lrecord_type_opaque, /* 21 */ | 246 lrecord_type_opaque, |
245 lrecord_type_opaque_ptr, /* 22 */ | 247 lrecord_type_opaque_ptr, |
246 lrecord_type_buffer, /* 23 */ | 248 lrecord_type_buffer, |
247 lrecord_type_extent, /* 24 */ | 249 lrecord_type_extent, |
248 lrecord_type_extent_info, /* 25 */ | 250 lrecord_type_extent_info, |
249 lrecord_type_extent_auxiliary, /* 26 */ | 251 lrecord_type_extent_auxiliary, |
250 lrecord_type_marker, /* 27 */ | 252 lrecord_type_marker, |
251 lrecord_type_event, /* 28 */ | 253 lrecord_type_event, |
252 #ifdef EVENT_DATA_AS_OBJECTS /* not defined */ | 254 #ifdef EVENT_DATA_AS_OBJECTS /* not defined */ |
253 lrecord_type_key_data, | 255 lrecord_type_key_data, |
254 lrecord_type_button_data, | 256 lrecord_type_button_data, |
255 lrecord_type_motion_data, | 257 lrecord_type_motion_data, |
256 lrecord_type_process_data, | 258 lrecord_type_process_data, |
258 lrecord_type_eval_data, | 260 lrecord_type_eval_data, |
259 lrecord_type_misc_user_data, | 261 lrecord_type_misc_user_data, |
260 lrecord_type_magic_eval_data, | 262 lrecord_type_magic_eval_data, |
261 lrecord_type_magic_data, | 263 lrecord_type_magic_data, |
262 #endif /* EVENT_DATA_AS_OBJECTS */ | 264 #endif /* EVENT_DATA_AS_OBJECTS */ |
263 lrecord_type_keymap, /* 29 */ | 265 lrecord_type_keymap, |
264 lrecord_type_command_builder, /* 30 */ | 266 lrecord_type_command_builder, |
265 lrecord_type_timeout, /* 31 */ | 267 lrecord_type_timeout, |
266 lrecord_type_specifier, /* 32 */ | 268 lrecord_type_specifier, |
267 lrecord_type_console, /* 33 */ | 269 lrecord_type_console, |
268 lrecord_type_device, /* 34 */ | 270 lrecord_type_device, |
269 lrecord_type_frame, /* 35 */ | 271 lrecord_type_frame, |
270 lrecord_type_window, /* 36 */ | 272 lrecord_type_window, |
271 lrecord_type_window_mirror, /* 37 */ | 273 lrecord_type_window_mirror, |
272 lrecord_type_window_configuration, /* 38 */ | 274 lrecord_type_window_configuration, |
273 lrecord_type_gui_item, /* 39 */ | 275 lrecord_type_gui_item, |
274 lrecord_type_popup_data, /* 40 */ | 276 lrecord_type_popup_data, |
275 lrecord_type_toolbar_button, /* 41 */ | 277 lrecord_type_toolbar_button, |
276 lrecord_type_scrollbar_instance, /* 42 */ | 278 lrecord_type_scrollbar_instance, |
277 lrecord_type_color_instance, /* 43 */ | 279 lrecord_type_color_instance, |
278 lrecord_type_font_instance, /* 44 */ | 280 lrecord_type_font_instance, |
279 lrecord_type_image_instance, /* 45 */ | 281 lrecord_type_image_instance, |
280 lrecord_type_glyph, /* 46 */ | 282 lrecord_type_glyph, |
281 lrecord_type_face, /* 47 */ | 283 lrecord_type_face, |
282 lrecord_type_database, /* 48 */ | 284 lrecord_type_database, |
283 lrecord_type_tooltalk_message, /* 49 */ | 285 lrecord_type_tooltalk_message, |
284 lrecord_type_tooltalk_pattern, /* 50 */ | 286 lrecord_type_tooltalk_pattern, |
285 lrecord_type_ldap, /* 51 */ | 287 lrecord_type_ldap, |
286 lrecord_type_pgconn, /* 52 */ | 288 lrecord_type_pgconn, |
287 lrecord_type_pgresult, /* 53 */ | 289 lrecord_type_pgresult, |
288 lrecord_type_devmode, /* 54 */ | 290 lrecord_type_devmode, |
289 lrecord_type_mswindows_dialog_id, /* 55 */ | 291 lrecord_type_mswindows_dialog_id, |
290 lrecord_type_case_table, /* 56 */ | 292 lrecord_type_case_table, |
291 lrecord_type_emacs_ffi, /* 57 */ | 293 lrecord_type_emacs_ffi, |
292 lrecord_type_emacs_gtk_object, /* 58 */ | 294 lrecord_type_emacs_gtk_object, |
293 lrecord_type_emacs_gtk_boxed, /* 59 */ | 295 lrecord_type_emacs_gtk_boxed, |
294 lrecord_type_weak_box, /* 60 */ | 296 lrecord_type_weak_box, |
295 lrecord_type_ephemeron, /* 61 */ | 297 lrecord_type_ephemeron, |
296 lrecord_type_bignum, /* 62 */ | 298 lrecord_type_bignum, |
297 lrecord_type_ratio, /* 63 */ | 299 lrecord_type_ratio, |
298 lrecord_type_bigfloat, /* 64 */ | 300 lrecord_type_bigfloat, |
299 #ifndef MC_ALLOC | 301 #ifndef MC_ALLOC |
300 lrecord_type_free, /* only used for "free" lrecords */ | 302 lrecord_type_free, /* only used for "free" lrecords */ |
301 lrecord_type_undefined, /* only used for debugging */ | 303 lrecord_type_undefined, /* only used for debugging */ |
302 #endif /* not MC_ALLOC */ | 304 #endif /* not MC_ALLOC */ |
303 lrecord_type_last_built_in_type /* 65 */ /* must be last */ | 305 #ifdef NEW_GC |
306 lrecord_type_string_indirect_data, | |
307 lrecord_type_string_direct_data, | |
308 lrecord_type_hash_table_entry, | |
309 lrecord_type_syntax_cache, | |
310 lrecord_type_buffer_text, | |
311 lrecord_type_compiled_function_args, | |
312 lrecord_type_tty_console, | |
313 lrecord_type_stream_console, | |
314 lrecord_type_dynarr, | |
315 lrecord_type_face_cachel, | |
316 lrecord_type_face_cachel_dynarr, | |
317 lrecord_type_glyph_cachel, | |
318 lrecord_type_glyph_cachel_dynarr, | |
319 lrecord_type_x_device, | |
320 lrecord_type_gtk_device, | |
321 lrecord_type_tty_device, | |
322 lrecord_type_mswindows_device, | |
323 lrecord_type_msprinter_device, | |
324 lrecord_type_x_frame, | |
325 lrecord_type_gtk_frame, | |
326 lrecord_type_mswindows_frame, | |
327 lrecord_type_gap_array_marker, | |
328 lrecord_type_gap_array, | |
329 lrecord_type_extent_list_marker, | |
330 lrecord_type_extent_list, | |
331 lrecord_type_stack_of_extents, | |
332 lrecord_type_tty_color_instance_data, | |
333 lrecord_type_tty_font_instance_data, | |
334 lrecord_type_specifier_caching, | |
335 lrecord_type_expose_ignore, | |
336 #endif /* NEW_GC */ | |
337 lrecord_type_last_built_in_type /* must be last */ | |
304 }; | 338 }; |
305 | 339 |
306 extern MODULE_API int lrecord_type_count; | 340 extern MODULE_API int lrecord_type_count; |
307 | 341 |
308 struct lrecord_implementation | 342 struct lrecord_implementation |
398 | 432 |
399 #define XRECORD_LHEADER_IMPLEMENTATION(obj) \ | 433 #define XRECORD_LHEADER_IMPLEMENTATION(obj) \ |
400 LHEADER_IMPLEMENTATION (XRECORD_LHEADER (obj)) | 434 LHEADER_IMPLEMENTATION (XRECORD_LHEADER (obj)) |
401 #define LHEADER_IMPLEMENTATION(lh) lrecord_implementations_table[(lh)->type] | 435 #define LHEADER_IMPLEMENTATION(lh) lrecord_implementations_table[(lh)->type] |
402 | 436 |
437 #include "gc.h" | |
438 | |
439 #ifdef NEW_GC | |
440 #include "vdb.h" | |
441 #endif /* NEW_GC */ | |
442 | |
403 extern int gc_in_progress; | 443 extern int gc_in_progress; |
404 | 444 |
405 #ifdef MC_ALLOC | 445 #ifdef MC_ALLOC |
406 #include "mc-alloc.h" | 446 #include "mc-alloc.h" |
407 | 447 |
408 #ifdef ALLOC_TYPE_STATS | 448 #ifdef ALLOC_TYPE_STATS |
409 void init_lrecord_stats (void); | 449 void init_lrecord_stats (void); |
410 void inc_lrecord_string_data_stats (Bytecount size); | |
411 void dec_lrecord_string_data_stats (Bytecount size); | |
412 void inc_lrecord_stats (Bytecount size, const struct lrecord_header *h); | 450 void inc_lrecord_stats (Bytecount size, const struct lrecord_header *h); |
413 void dec_lrecord_stats (Bytecount size_including_overhead, | 451 void dec_lrecord_stats (Bytecount size_including_overhead, |
414 const struct lrecord_header *h); | 452 const struct lrecord_header *h); |
453 int lrecord_stats_heap_size (void); | |
415 #endif /* ALLOC_TYPE_STATS */ | 454 #endif /* ALLOC_TYPE_STATS */ |
416 | 455 |
417 /* Tell mc-alloc how to call a finalizer. */ | 456 /* Tell mc-alloc how to call a finalizer. */ |
457 #ifdef NEW_GC | |
458 #define MC_ALLOC_CALL_FINALIZER(ptr) \ | |
459 { \ | |
460 Lisp_Object MCACF_obj = wrap_pointer_1 (ptr); \ | |
461 struct lrecord_header *MCACF_lheader = XRECORD_LHEADER (MCACF_obj); \ | |
462 if (XRECORD_LHEADER (MCACF_obj) && LRECORDP (MCACF_obj) \ | |
463 && !LRECORD_FREE_P (MCACF_lheader) ) \ | |
464 { \ | |
465 const struct lrecord_implementation *MCACF_implementation \ | |
466 = LHEADER_IMPLEMENTATION (MCACF_lheader); \ | |
467 if (MCACF_implementation && MCACF_implementation->finalizer) \ | |
468 { \ | |
469 GC_STAT_FINALIZED; \ | |
470 MCACF_implementation->finalizer (ptr, 0); \ | |
471 } \ | |
472 } \ | |
473 } while (0) | |
474 #else /* not NEW_GC */ | |
418 #define MC_ALLOC_CALL_FINALIZER(ptr) \ | 475 #define MC_ALLOC_CALL_FINALIZER(ptr) \ |
419 { \ | 476 { \ |
420 Lisp_Object MCACF_obj = wrap_pointer_1 (ptr); \ | 477 Lisp_Object MCACF_obj = wrap_pointer_1 (ptr); \ |
421 struct lrecord_header *MCACF_lheader = XRECORD_LHEADER (MCACF_obj); \ | 478 struct lrecord_header *MCACF_lheader = XRECORD_LHEADER (MCACF_obj); \ |
422 if (XRECORD_LHEADER (MCACF_obj) && LRECORDP (MCACF_obj) \ | 479 if (XRECORD_LHEADER (MCACF_obj) && LRECORDP (MCACF_obj) \ |
426 = LHEADER_IMPLEMENTATION (MCACF_lheader); \ | 483 = LHEADER_IMPLEMENTATION (MCACF_lheader); \ |
427 if (MCACF_implementation && MCACF_implementation->finalizer) \ | 484 if (MCACF_implementation && MCACF_implementation->finalizer) \ |
428 MCACF_implementation->finalizer (ptr, 0); \ | 485 MCACF_implementation->finalizer (ptr, 0); \ |
429 } \ | 486 } \ |
430 } while (0) | 487 } while (0) |
488 #endif /* not NEW_GC */ | |
431 | 489 |
432 /* Tell mc-alloc how to call a finalizer for disksave. */ | 490 /* Tell mc-alloc how to call a finalizer for disksave. */ |
433 #define MC_ALLOC_CALL_FINALIZER_FOR_DISKSAVE(ptr) \ | 491 #define MC_ALLOC_CALL_FINALIZER_FOR_DISKSAVE(ptr) \ |
434 { \ | 492 { \ |
435 Lisp_Object MCACF_obj = wrap_pointer_1 (ptr); \ | 493 Lisp_Object MCACF_obj = wrap_pointer_1 (ptr); \ |
950 | 1008 |
951 enum memory_description_type | 1009 enum memory_description_type |
952 { | 1010 { |
953 XD_LISP_OBJECT_ARRAY, | 1011 XD_LISP_OBJECT_ARRAY, |
954 XD_LISP_OBJECT, | 1012 XD_LISP_OBJECT, |
1013 #ifdef NEW_GC | |
1014 XD_LISP_OBJECT_BLOCK_PTR, | |
1015 #endif /* NEW_GC */ | |
955 XD_LO_LINK, | 1016 XD_LO_LINK, |
956 XD_OPAQUE_PTR, | 1017 XD_OPAQUE_PTR, |
957 XD_OPAQUE_PTR_CONVERTIBLE, | 1018 XD_OPAQUE_PTR_CONVERTIBLE, |
958 XD_OPAQUE_DATA_CONVERTIBLE, | 1019 XD_OPAQUE_DATA_CONVERTIBLE, |
959 XD_OPAQUE_DATA_PTR, | 1020 XD_OPAQUE_DATA_PTR, |
1086 #define XD_DYNARR_DESC(base_type, sub_desc) \ | 1147 #define XD_DYNARR_DESC(base_type, sub_desc) \ |
1087 { XD_BLOCK_PTR, offsetof (base_type, base), XD_INDIRECT(1, 0), {sub_desc} },\ | 1148 { XD_BLOCK_PTR, offsetof (base_type, base), XD_INDIRECT(1, 0), {sub_desc} },\ |
1088 { XD_INT, offsetof (base_type, cur) }, \ | 1149 { XD_INT, offsetof (base_type, cur) }, \ |
1089 { XD_INT_RESET, offsetof (base_type, max), XD_INDIRECT(1, 0) } \ | 1150 { XD_INT_RESET, offsetof (base_type, max), XD_INDIRECT(1, 0) } \ |
1090 | 1151 |
1152 #ifdef NEW_GC | |
1153 #define XD_LISP_DYNARR_DESC(base_type, sub_desc) \ | |
1154 { XD_LISP_OBJECT_BLOCK_PTR, offsetof (base_type, base), \ | |
1155 XD_INDIRECT(1, 0), {sub_desc} }, \ | |
1156 { XD_INT, offsetof (base_type, cur) }, \ | |
1157 { XD_INT_RESET, offsetof (base_type, max), XD_INDIRECT(1, 0) } | |
1158 #endif /* not NEW_GC */ | |
1159 | |
1091 /* DEFINE_LRECORD_IMPLEMENTATION is for objects with constant size. | 1160 /* DEFINE_LRECORD_IMPLEMENTATION is for objects with constant size. |
1092 DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION is for objects whose size varies. | 1161 DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION is for objects whose size varies. |
1093 */ | 1162 */ |
1094 | 1163 |
1095 #if defined (ERROR_CHECK_TYPES) | 1164 #if defined (ERROR_CHECK_TYPES) |
1672 - To free a Lisp_Object manually, use free_lrecord. */ | 1741 - To free a Lisp_Object manually, use free_lrecord. */ |
1673 | 1742 |
1674 void *alloc_lrecord (Bytecount size, | 1743 void *alloc_lrecord (Bytecount size, |
1675 const struct lrecord_implementation *); | 1744 const struct lrecord_implementation *); |
1676 | 1745 |
1746 void *alloc_lrecord_array (Bytecount size, int elemcount, | |
1747 const struct lrecord_implementation *); | |
1748 | |
1677 #define alloc_lrecord_type(type, lrecord_implementation) \ | 1749 #define alloc_lrecord_type(type, lrecord_implementation) \ |
1678 ((type *) alloc_lrecord (sizeof (type), lrecord_implementation)) | 1750 ((type *) alloc_lrecord (sizeof (type), lrecord_implementation)) |
1679 | 1751 |
1680 void *noseeum_alloc_lrecord (Bytecount size, | 1752 void *noseeum_alloc_lrecord (Bytecount size, |
1681 const struct lrecord_implementation *); | 1753 const struct lrecord_implementation *); |