comparison src/alloc.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 1c2a4e4e81d9
children 73051095a712
comparison
equal deleted inserted replaced
3262:79d41cfd8e6b 3263:d674024a8674
189 /* Very cheesy ways of figuring out how much memory is being used for 189 /* Very cheesy ways of figuring out how much memory is being used for
190 data. #### Need better (system-dependent) ways. */ 190 data. #### Need better (system-dependent) ways. */
191 void *minimum_address_seen; 191 void *minimum_address_seen;
192 void *maximum_address_seen; 192 void *maximum_address_seen;
193 193
194 #ifndef MC_ALLOC 194 #ifndef NEW_GC
195 int 195 int
196 c_readonly (Lisp_Object obj) 196 c_readonly (Lisp_Object obj)
197 { 197 {
198 return POINTER_TYPE_P (XTYPE (obj)) && C_READONLY (obj); 198 return POINTER_TYPE_P (XTYPE (obj)) && C_READONLY (obj);
199 } 199 }
200 #endif /* MC_ALLOC */ 200 #endif /* not NEW_GC */
201 201
202 int 202 int
203 lisp_readonly (Lisp_Object obj) 203 lisp_readonly (Lisp_Object obj)
204 { 204 {
205 return POINTER_TYPE_P (XTYPE (obj)) && LISP_READONLY (obj); 205 return POINTER_TYPE_P (XTYPE (obj)) && LISP_READONLY (obj);
214 214
215 /* Non-zero means ignore malloc warnings. Set during initialization. */ 215 /* Non-zero means ignore malloc warnings. Set during initialization. */
216 int ignore_malloc_warnings; 216 int ignore_malloc_warnings;
217 217
218 218
219 #ifndef MC_ALLOC 219 #ifndef NEW_GC
220 void *breathing_space; 220 void *breathing_space;
221 221
222 void 222 void
223 release_breathing_space (void) 223 release_breathing_space (void)
224 { 224 {
227 void *tmp = breathing_space; 227 void *tmp = breathing_space;
228 breathing_space = 0; 228 breathing_space = 0;
229 xfree (tmp, void *); 229 xfree (tmp, void *);
230 } 230 }
231 } 231 }
232 #endif /* not MC_ALLOC */ 232 #endif /* not NEW_GC */
233 233
234 /* malloc calls this if it finds we are near exhausting storage */ 234 /* malloc calls this if it finds we are near exhausting storage */
235 void 235 void
236 malloc_warning (const char *str) 236 malloc_warning (const char *str)
237 { 237 {
256 It's better to loop garbage-collecting (we might reclaim enough 256 It's better to loop garbage-collecting (we might reclaim enough
257 to win) than to loop beeping and barfing "Memory exhausted" 257 to win) than to loop beeping and barfing "Memory exhausted"
258 */ 258 */
259 consing_since_gc = gc_cons_threshold + 1; 259 consing_since_gc = gc_cons_threshold + 1;
260 recompute_need_to_garbage_collect (); 260 recompute_need_to_garbage_collect ();
261 #ifndef MC_ALLOC 261 #ifndef NEW_GC
262 release_breathing_space (); 262 release_breathing_space ();
263 #endif /* not MC_ALLOC */ 263 #endif /* not NEW_GC */
264 264
265 /* Flush some histories which might conceivably contain garbalogical 265 /* Flush some histories which might conceivably contain garbalogical
266 inhibitors. */ 266 inhibitors. */
267 if (!NILP (Fboundp (Qvalues))) 267 if (!NILP (Fboundp (Qvalues)))
268 Fset (Qvalues, Qnil); 268 Fset (Qvalues, Qnil);
300 assert (!regex_malloc_disallowed); \ 300 assert (!regex_malloc_disallowed); \
301 in_malloc = 1; \ 301 in_malloc = 1; \
302 } \ 302 } \
303 while (0) 303 while (0)
304 304
305 #ifdef MC_ALLOC 305 #ifdef NEW_GC
306 #define FREE_OR_REALLOC_BEGIN(block) \ 306 #define FREE_OR_REALLOC_BEGIN(block) \
307 do \ 307 do \
308 { \ 308 { \
309 /* Unbelievably, calling free() on 0xDEADBEEF doesn't cause an \ 309 /* Unbelievably, calling free() on 0xDEADBEEF doesn't cause an \
310 error until much later on for many system mallocs, such as \ 310 error until much later on for many system mallocs, such as \
311 the one that comes with Solaris 2.3. FMH!! */ \ 311 the one that comes with Solaris 2.3. FMH!! */ \
312 assert (block != (void *) 0xDEADBEEF); \ 312 assert (block != (void *) 0xDEADBEEF); \
313 MALLOC_BEGIN (); \ 313 MALLOC_BEGIN (); \
314 } \ 314 } \
315 while (0) 315 while (0)
316 #else /* not MC_ALLOC */ 316 #else /* not NEW_GC */
317 #define FREE_OR_REALLOC_BEGIN(block) \ 317 #define FREE_OR_REALLOC_BEGIN(block) \
318 do \ 318 do \
319 { \ 319 { \
320 /* Unbelievably, calling free() on 0xDEADBEEF doesn't cause an \ 320 /* Unbelievably, calling free() on 0xDEADBEEF doesn't cause an \
321 error until much later on for many system mallocs, such as \ 321 error until much later on for many system mallocs, such as \
327 DUMPEDP. */ \ 327 DUMPEDP. */ \
328 assert (!DUMPEDP (block)); \ 328 assert (!DUMPEDP (block)); \
329 MALLOC_BEGIN (); \ 329 MALLOC_BEGIN (); \
330 } \ 330 } \
331 while (0) 331 while (0)
332 #endif /* not MC_ALLOC */ 332 #endif /* not NEW_GC */
333 333
334 #define MALLOC_END() \ 334 #define MALLOC_END() \
335 do \ 335 do \
336 { \ 336 { \
337 in_malloc = 0; \ 337 in_malloc = 0; \
413 MALLOC_END (); 413 MALLOC_END ();
414 } 414 }
415 415
416 #ifdef ERROR_CHECK_GC 416 #ifdef ERROR_CHECK_GC
417 417
418 #ifndef MC_ALLOC 418 #ifndef NEW_GC
419 static void 419 static void
420 deadbeef_memory (void *ptr, Bytecount size) 420 deadbeef_memory (void *ptr, Bytecount size)
421 { 421 {
422 UINT_32_BIT *ptr4 = (UINT_32_BIT *) ptr; 422 UINT_32_BIT *ptr4 = (UINT_32_BIT *) ptr;
423 Bytecount beefs = size >> 2; 423 Bytecount beefs = size >> 2;
424 424
425 /* In practice, size will always be a multiple of four. */ 425 /* In practice, size will always be a multiple of four. */
426 while (beefs--) 426 while (beefs--)
427 (*ptr4++) = 0xDEADBEEF; /* -559038737 base 10 */ 427 (*ptr4++) = 0xDEADBEEF; /* -559038737 base 10 */
428 } 428 }
429 #endif /* not MC_ALLOC */ 429 #endif /* not NEW_GC */
430 430
431 #else /* !ERROR_CHECK_GC */ 431 #else /* !ERROR_CHECK_GC */
432 432
433 433
434 #define deadbeef_memory(ptr, size) 434 #define deadbeef_memory(ptr, size)
453 return xstrdup (s); 453 return xstrdup (s);
454 } 454 }
455 #endif /* NEED_STRDUP */ 455 #endif /* NEED_STRDUP */
456 456
457 457
458 #ifndef MC_ALLOC 458 #ifndef NEW_GC
459 static void * 459 static void *
460 allocate_lisp_storage (Bytecount size) 460 allocate_lisp_storage (Bytecount size)
461 { 461 {
462 void *val = xmalloc (size); 462 void *val = xmalloc (size);
463 /* We don't increment the cons counter anymore. Calling functions do 463 /* We don't increment the cons counter anymore. Calling functions do
478 if (need_to_check_c_alloca) 478 if (need_to_check_c_alloca)
479 xemacs_c_alloca (0); 479 xemacs_c_alloca (0);
480 480
481 return val; 481 return val;
482 } 482 }
483 #endif /* not MC_ALLOC */ 483 #endif /* not NEW_GC */
484 484
485 #if defined (MC_ALLOC) && defined (ALLOC_TYPE_STATS) 485 #if defined (NEW_GC) && defined (ALLOC_TYPE_STATS)
486 static struct 486 static struct
487 { 487 {
488 int instances_in_use; 488 int instances_in_use;
489 int bytes_in_use; 489 int bytes_in_use;
490 int bytes_in_use_including_overhead; 490 int bytes_in_use_including_overhead;
537 for (i = 0; i < (countof (lrecord_implementations_table) 537 for (i = 0; i < (countof (lrecord_implementations_table)
538 + MODULE_DEFINABLE_TYPE_COUNT); i++) 538 + MODULE_DEFINABLE_TYPE_COUNT); i++)
539 size += lrecord_stats[i].bytes_in_use; 539 size += lrecord_stats[i].bytes_in_use;
540 return size; 540 return size;
541 } 541 }
542 #endif /* not (MC_ALLOC && ALLOC_TYPE_STATS) */ 542 #endif /* NEW_GC && ALLOC_TYPE_STATS */
543 543
544 #ifndef MC_ALLOC 544 #ifndef NEW_GC
545 /* lcrecords are chained together through their "next" field. 545 /* lcrecords are chained together through their "next" field.
546 After doing the mark phase, GC will walk this linked list 546 After doing the mark phase, GC will walk this linked list
547 and free any lcrecord which hasn't been marked. */ 547 and free any lcrecord which hasn't been marked. */
548 static struct old_lcrecord_header *all_lcrecords; 548 static struct old_lcrecord_header *all_lcrecords;
549 #endif /* not MC_ALLOC */ 549 #endif /* not NEW_GC */
550 550
551 #ifdef MC_ALLOC 551 #ifdef NEW_GC
552 /* The basic lrecord allocation functions. See lrecord.h for details. */ 552 /* The basic lrecord allocation functions. See lrecord.h for details. */
553 void * 553 void *
554 alloc_lrecord (Bytecount size, 554 alloc_lrecord (Bytecount size,
555 const struct lrecord_implementation *implementation) 555 const struct lrecord_implementation *implementation)
556 { 556 {
565 gc_checking_assert (LRECORD_FREE_P (lheader)); 565 gc_checking_assert (LRECORD_FREE_P (lheader));
566 set_lheader_implementation (lheader, implementation); 566 set_lheader_implementation (lheader, implementation);
567 #ifdef ALLOC_TYPE_STATS 567 #ifdef ALLOC_TYPE_STATS
568 inc_lrecord_stats (size, lheader); 568 inc_lrecord_stats (size, lheader);
569 #endif /* ALLOC_TYPE_STATS */ 569 #endif /* ALLOC_TYPE_STATS */
570 if (implementation->finalizer)
571 add_finalizable_obj (wrap_pointer_1 (lheader));
570 INCREMENT_CONS_COUNTER (size, implementation->name); 572 INCREMENT_CONS_COUNTER (size, implementation->name);
571 return lheader; 573 return lheader;
572 } 574 }
573 575
574 576
587 gc_checking_assert (LRECORD_FREE_P (lheader)); 589 gc_checking_assert (LRECORD_FREE_P (lheader));
588 set_lheader_implementation (lheader, implementation); 590 set_lheader_implementation (lheader, implementation);
589 #ifdef ALLOC_TYPE_STATS 591 #ifdef ALLOC_TYPE_STATS
590 inc_lrecord_stats (size, lheader); 592 inc_lrecord_stats (size, lheader);
591 #endif /* ALLOC_TYPE_STATS */ 593 #endif /* ALLOC_TYPE_STATS */
594 if (implementation->finalizer)
595 add_finalizable_obj (wrap_pointer_1 (lheader));
592 NOSEEUM_INCREMENT_CONS_COUNTER (size, implementation->name); 596 NOSEEUM_INCREMENT_CONS_COUNTER (size, implementation->name);
593 return lheader; 597 return lheader;
594 } 598 }
595 599
596 #ifdef NEW_GC
597 void * 600 void *
598 alloc_lrecord_array (Bytecount size, int elemcount, 601 alloc_lrecord_array (Bytecount size, int elemcount,
599 const struct lrecord_implementation *implementation) 602 const struct lrecord_implementation *implementation)
600 { 603 {
601 struct lrecord_header *lheader; 604 struct lrecord_header *lheader;
617 set_lheader_implementation (lh, implementation); 620 set_lheader_implementation (lh, implementation);
618 lh->uid = lrecord_uid_counter++; 621 lh->uid = lrecord_uid_counter++;
619 #ifdef ALLOC_TYPE_STATS 622 #ifdef ALLOC_TYPE_STATS
620 inc_lrecord_stats (size, lh); 623 inc_lrecord_stats (size, lh);
621 #endif /* not ALLOC_TYPE_STATS */ 624 #endif /* not ALLOC_TYPE_STATS */
625 if (implementation->finalizer)
626 add_finalizable_obj (wrap_pointer_1 (lh));
622 } 627 }
623 INCREMENT_CONS_COUNTER (size * elemcount, implementation->name); 628 INCREMENT_CONS_COUNTER (size * elemcount, implementation->name);
624 return lheader; 629 return lheader;
625 } 630 }
626 #endif /* NEW_GC */
627 631
628 void 632 void
629 free_lrecord (Lisp_Object lrecord) 633 free_lrecord (Lisp_Object UNUSED (lrecord))
630 { 634 {
631 #ifndef NEW_GC 635 /* Manual frees are not allowed with asynchronous finalization */
632 gc_checking_assert (!gc_in_progress); 636 return;
633 #endif /* not NEW_GC */ 637 }
634 gc_checking_assert (!LRECORD_FREE_P (XRECORD_LHEADER (lrecord))); 638 #else /* not NEW_GC */
635 gc_checking_assert (!XRECORD_LHEADER (lrecord)->free);
636
637 #ifdef NEW_GC
638 GC_STAT_EXPLICITLY_TRIED_FREED;
639 /* Ignore requests to manual free objects while in garbage collection. */
640 if (write_barrier_enabled || gc_in_progress)
641 return;
642
643 GC_STAT_EXPLICITLY_FREED;
644 #endif /* NEW_GC */
645
646 MC_ALLOC_CALL_FINALIZER (XPNTR (lrecord));
647 mc_free (XPNTR (lrecord));
648 recompute_need_to_garbage_collect ();
649 }
650 #else /* not MC_ALLOC */
651 639
652 /* The most basic of the lcrecord allocation functions. Not usually called 640 /* The most basic of the lcrecord allocation functions. Not usually called
653 directly. Allocates an lrecord not managed by any lcrecord-list, of a 641 directly. Allocates an lrecord not managed by any lcrecord-list, of a
654 specified size. See lrecord.h. */ 642 specified size. See lrecord.h. */
655 643
717 lrecord->implementation->finalizer (lrecord, 0); 705 lrecord->implementation->finalizer (lrecord, 0);
718 xfree (lrecord); 706 xfree (lrecord);
719 return; 707 return;
720 } 708 }
721 #endif /* Unused */ 709 #endif /* Unused */
722 #endif /* not MC_ALLOC */ 710 #endif /* not NEW_GC */
723 711
724 712
725 static void 713 static void
726 disksave_object_finalization_1 (void) 714 disksave_object_finalization_1 (void)
727 { 715 {
728 #ifdef MC_ALLOC 716 #ifdef NEW_GC
729 mc_finalize_for_disksave (); 717 mc_finalize_for_disksave ();
730 #else /* not MC_ALLOC */ 718 #else /* not NEW_GC */
731 struct old_lcrecord_header *header; 719 struct old_lcrecord_header *header;
732 720
733 for (header = all_lcrecords; header; header = header->next) 721 for (header = all_lcrecords; header; header = header->next)
734 { 722 {
735 if (LHEADER_IMPLEMENTATION (&header->lheader)->finalizer && 723 if (LHEADER_IMPLEMENTATION (&header->lheader)->finalizer &&
736 !header->free) 724 !header->free)
737 LHEADER_IMPLEMENTATION (&header->lheader)->finalizer (header, 1); 725 LHEADER_IMPLEMENTATION (&header->lheader)->finalizer (header, 1);
738 } 726 }
739 #endif /* not MC_ALLOC */ 727 #endif /* not NEW_GC */
740 } 728 }
741 729
742 /* Bitwise copy all parts of a Lisp object other than the header */ 730 /* Bitwise copy all parts of a Lisp object other than the header */
743 731
744 void 732 void
749 Bytecount size = lisp_object_size (src); 737 Bytecount size = lisp_object_size (src);
750 738
751 assert (imp == XRECORD_LHEADER_IMPLEMENTATION (dst)); 739 assert (imp == XRECORD_LHEADER_IMPLEMENTATION (dst));
752 assert (size == lisp_object_size (dst)); 740 assert (size == lisp_object_size (dst));
753 741
754 #ifdef MC_ALLOC 742 #ifdef NEW_GC
755 memcpy ((char *) XRECORD_LHEADER (dst) + sizeof (struct lrecord_header), 743 memcpy ((char *) XRECORD_LHEADER (dst) + sizeof (struct lrecord_header),
756 (char *) XRECORD_LHEADER (src) + sizeof (struct lrecord_header), 744 (char *) XRECORD_LHEADER (src) + sizeof (struct lrecord_header),
757 size - sizeof (struct lrecord_header)); 745 size - sizeof (struct lrecord_header));
758 #else /* not MC_ALLOC */ 746 #else /* not NEW_GC */
759 if (imp->basic_p) 747 if (imp->basic_p)
760 memcpy ((char *) XRECORD_LHEADER (dst) + sizeof (struct lrecord_header), 748 memcpy ((char *) XRECORD_LHEADER (dst) + sizeof (struct lrecord_header),
761 (char *) XRECORD_LHEADER (src) + sizeof (struct lrecord_header), 749 (char *) XRECORD_LHEADER (src) + sizeof (struct lrecord_header),
762 size - sizeof (struct lrecord_header)); 750 size - sizeof (struct lrecord_header));
763 else 751 else
764 memcpy ((char *) XRECORD_LHEADER (dst) + 752 memcpy ((char *) XRECORD_LHEADER (dst) +
765 sizeof (struct old_lcrecord_header), 753 sizeof (struct old_lcrecord_header),
766 (char *) XRECORD_LHEADER (src) + 754 (char *) XRECORD_LHEADER (src) +
767 sizeof (struct old_lcrecord_header), 755 sizeof (struct old_lcrecord_header),
768 size - sizeof (struct old_lcrecord_header)); 756 size - sizeof (struct old_lcrecord_header));
769 #endif /* not MC_ALLOC */ 757 #endif /* not NEW_GC */
770 } 758 }
771 759
772 760
773 /************************************************************************/ 761 /************************************************************************/
774 /* Debugger support */ 762 /* Debugger support */
812 { 800 {
813 return EQ (obj1, obj2); 801 return EQ (obj1, obj2);
814 } 802 }
815 803
816 804
817 #ifdef MC_ALLOC 805 #ifdef NEW_GC
818 #define DECLARE_FIXED_TYPE_ALLOC(type, structture) struct __foo__ 806 #define DECLARE_FIXED_TYPE_ALLOC(type, structture) struct __foo__
819 #else 807 #else
820 /************************************************************************/ 808 /************************************************************************/
821 /* Fixed-size type macros */ 809 /* Fixed-size type macros */
822 /************************************************************************/ 810 /************************************************************************/
1162 gc_count_num_##type##_freelist++; \ 1150 gc_count_num_##type##_freelist++; \
1163 } while (0) 1151 } while (0)
1164 #else 1152 #else
1165 #define FREE_FIXED_TYPE_WHEN_NOT_IN_GC(type, structtype, ptr) 1153 #define FREE_FIXED_TYPE_WHEN_NOT_IN_GC(type, structtype, ptr)
1166 #endif 1154 #endif
1167 #endif /* not MC_ALLOC */ 1155 #endif /* NEW_GC */
1168 1156
1169 #ifdef MC_ALLOC 1157 #ifdef NEW_GC
1170 #define ALLOCATE_FIXED_TYPE_AND_SET_IMPL(type, lisp_type, var, lrec_ptr) \ 1158 #define ALLOCATE_FIXED_TYPE_AND_SET_IMPL(type, lisp_type, var, lrec_ptr) \
1171 do { \ 1159 do { \
1172 (var) = alloc_lrecord_type (lisp_type, lrec_ptr); \ 1160 (var) = alloc_lrecord_type (lisp_type, lrec_ptr); \
1173 } while (0) 1161 } while (0)
1174 #define NOSEEUM_ALLOCATE_FIXED_TYPE_AND_SET_IMPL(type, lisp_type, var, \ 1162 #define NOSEEUM_ALLOCATE_FIXED_TYPE_AND_SET_IMPL(type, lisp_type, var, \
1175 lrec_ptr) \ 1163 lrec_ptr) \
1176 do { \ 1164 do { \
1177 (var) = noseeum_alloc_lrecord_type (lisp_type, lrec_ptr); \ 1165 (var) = noseeum_alloc_lrecord_type (lisp_type, lrec_ptr); \
1178 } while (0) 1166 } while (0)
1179 #else /* not MC_ALLOC */ 1167 #else /* not NEW_GC */
1180 #define ALLOCATE_FIXED_TYPE_AND_SET_IMPL(type, lisp_type, var, lrec_ptr) \ 1168 #define ALLOCATE_FIXED_TYPE_AND_SET_IMPL(type, lisp_type, var, lrec_ptr) \
1181 do \ 1169 do \
1182 { \ 1170 { \
1183 ALLOCATE_FIXED_TYPE (type, lisp_type, var); \ 1171 ALLOCATE_FIXED_TYPE (type, lisp_type, var); \
1184 set_lheader_implementation (&(var)->lheader, lrec_ptr); \ 1172 set_lheader_implementation (&(var)->lheader, lrec_ptr); \
1188 do \ 1176 do \
1189 { \ 1177 { \
1190 NOSEEUM_ALLOCATE_FIXED_TYPE (type, lisp_type, var); \ 1178 NOSEEUM_ALLOCATE_FIXED_TYPE (type, lisp_type, var); \
1191 set_lheader_implementation (&(var)->lheader, lrec_ptr); \ 1179 set_lheader_implementation (&(var)->lheader, lrec_ptr); \
1192 } while (0) 1180 } while (0)
1193 #endif /* MC_ALLOC */ 1181 #endif /* not NEW_GC */
1194 1182
1195 1183
1196 1184
1197 /************************************************************************/ 1185 /************************************************************************/
1198 /* Cons allocation */ 1186 /* Cons allocation */
2290 string_plist (Lisp_Object string) 2278 string_plist (Lisp_Object string)
2291 { 2279 {
2292 return *string_plist_ptr (string); 2280 return *string_plist_ptr (string);
2293 } 2281 }
2294 2282
2295 #ifndef MC_ALLOC 2283 #ifndef NEW_GC
2296 /* No `finalize', or `hash' methods. 2284 /* No `finalize', or `hash' methods.
2297 internal_hash() already knows how to hash strings and finalization 2285 internal_hash() already knows how to hash strings and finalization
2298 is done with the ADDITIONAL_FREE_string macro, which is the 2286 is done with the ADDITIONAL_FREE_string macro, which is the
2299 standard way to do finalization when using 2287 standard way to do finalization when using
2300 SWEEP_FIXED_TYPE_BLOCK(). */ 2288 SWEEP_FIXED_TYPE_BLOCK(). */
2307 string_getprop, 2295 string_getprop,
2308 string_putprop, 2296 string_putprop,
2309 string_remprop, 2297 string_remprop,
2310 string_plist, 2298 string_plist,
2311 Lisp_String); 2299 Lisp_String);
2312 #endif /* not MC_ALLOC */ 2300 #endif /* not NEW_GC */
2313 2301
2314 #ifdef NEW_GC 2302 #ifdef NEW_GC
2315 #define STRING_FULLSIZE(size) \ 2303 #define STRING_FULLSIZE(size) \
2316 ALIGN_SIZE (FLEXIBLE_ARRAY_STRUCT_SIZEOF (Lisp_String_Direct_Data, Lisp_Object, data, (size) + 1), sizeof (Lisp_Object *)); 2304 ALIGN_SIZE (FLEXIBLE_ARRAY_STRUCT_SIZEOF (Lisp_String_Direct_Data, Lisp_Object, data, (size) + 1), sizeof (Lisp_Object *));
2317 #else /* not NEW_GC */ 2305 #else /* not NEW_GC */
2346 2334
2347 #define STRING_CHARS_FREE_P(ptr) ((ptr)->string == NULL) 2335 #define STRING_CHARS_FREE_P(ptr) ((ptr)->string == NULL)
2348 #define MARK_STRING_CHARS_AS_FREE(ptr) ((void) ((ptr)->string = NULL)) 2336 #define MARK_STRING_CHARS_AS_FREE(ptr) ((void) ((ptr)->string = NULL))
2349 #endif /* not NEW_GC */ 2337 #endif /* not NEW_GC */
2350 2338
2351 #ifdef MC_ALLOC 2339 #ifdef NEW_GC
2352 #ifndef NEW_GC
2353 static void
2354 finalize_string (void *header, int for_disksave)
2355 {
2356 if (!for_disksave)
2357 {
2358 Lisp_String *s = (Lisp_String *) header;
2359 Bytecount size = s->size_;
2360 if (BIG_STRING_SIZE_P (size))
2361 xfree (s->data_, Ibyte *);
2362 }
2363 }
2364
2365 DEFINE_LRECORD_IMPLEMENTATION_WITH_PROPS ("string", string,
2366 1, /*dumpable-flag*/
2367 mark_string, print_string,
2368 finalize_string,
2369 string_equal, 0,
2370 string_description,
2371 string_getprop,
2372 string_putprop,
2373 string_remprop,
2374 string_plist,
2375 Lisp_String);
2376 #else /* NEW_GC */
2377 DEFINE_LRECORD_IMPLEMENTATION_WITH_PROPS ("string", string, 2340 DEFINE_LRECORD_IMPLEMENTATION_WITH_PROPS ("string", string,
2378 1, /*dumpable-flag*/ 2341 1, /*dumpable-flag*/
2379 mark_string, print_string, 2342 mark_string, print_string,
2380 0, 2343 0,
2381 string_equal, 0, 2344 string_equal, 0,
2420 1, /*dumpable-flag*/ 2383 1, /*dumpable-flag*/
2421 0, 0, 0, 0, 0, 2384 0, 0, 0, 0, 0,
2422 string_indirect_data_description, 2385 string_indirect_data_description,
2423 Lisp_String_Indirect_Data); 2386 Lisp_String_Indirect_Data);
2424 #endif /* NEW_GC */ 2387 #endif /* NEW_GC */
2425 #endif /* MC_ALLOC */
2426 2388
2427 #ifndef NEW_GC 2389 #ifndef NEW_GC
2428 struct string_chars 2390 struct string_chars
2429 { 2391 {
2430 Lisp_String *string; 2392 Lisp_String *string;
2522 Lisp_String *s; 2484 Lisp_String *s;
2523 Bytecount fullsize = STRING_FULLSIZE (length); 2485 Bytecount fullsize = STRING_FULLSIZE (length);
2524 2486
2525 assert (length >= 0 && fullsize > 0); 2487 assert (length >= 0 && fullsize > 0);
2526 2488
2527 #ifdef MC_ALLOC 2489 #ifdef NEW_GC
2528 s = alloc_lrecord_type (Lisp_String, &lrecord_string); 2490 s = alloc_lrecord_type (Lisp_String, &lrecord_string);
2529 #else /* not MC_ALLOC */ 2491 #else /* not NEW_GC */
2530 /* Allocate the string header */ 2492 /* Allocate the string header */
2531 ALLOCATE_FIXED_TYPE (string, Lisp_String, s); 2493 ALLOCATE_FIXED_TYPE (string, Lisp_String, s);
2532 xzero (*s); 2494 xzero (*s);
2533 set_lheader_implementation (&s->u.lheader, &lrecord_string); 2495 set_lheader_implementation (&s->u.lheader, &lrecord_string);
2534 #endif /* not MC_ALLOC */ 2496 #endif /* not NEW_GC */
2535 2497
2536 /* The above allocations set the UID field, which overlaps with the 2498 /* The above allocations set the UID field, which overlaps with the
2537 ascii-length field, to some non-zero value. We need to zero it. */ 2499 ascii-length field, to some non-zero value. We need to zero it. */
2538 XSET_STRING_ASCII_BEGIN (wrap_string (s), 0); 2500 XSET_STRING_ASCII_BEGIN (wrap_string (s), 0);
2539 2501
2614 newfullsize)); 2576 newfullsize));
2615 if (delta > 0 && pos >= 0) 2577 if (delta > 0 && pos >= 0)
2616 memmove (XSTRING_DATA (s) + pos + delta, XSTRING_DATA (s) + pos, 2578 memmove (XSTRING_DATA (s) + pos + delta, XSTRING_DATA (s) + pos,
2617 len); 2579 len);
2618 2580
2619 #else /* NEW_GC */ 2581 #else /* not NEW_GC */
2620 oldfullsize = STRING_FULLSIZE (XSTRING_LENGTH (s)); 2582 oldfullsize = STRING_FULLSIZE (XSTRING_LENGTH (s));
2621 newfullsize = STRING_FULLSIZE (XSTRING_LENGTH (s) + delta); 2583 newfullsize = STRING_FULLSIZE (XSTRING_LENGTH (s) + delta);
2622 2584
2623 if (BIG_STRING_FULLSIZE_P (oldfullsize)) 2585 if (BIG_STRING_FULLSIZE_P (oldfullsize))
2624 { 2586 {
2927 /* Make sure we find out about bad make_string_nocopy's when they happen */ 2889 /* Make sure we find out about bad make_string_nocopy's when they happen */
2928 #if defined (ERROR_CHECK_TEXT) && defined (MULE) 2890 #if defined (ERROR_CHECK_TEXT) && defined (MULE)
2929 bytecount_to_charcount (contents, length); /* Just for the assertions */ 2891 bytecount_to_charcount (contents, length); /* Just for the assertions */
2930 #endif 2892 #endif
2931 2893
2932 #ifdef MC_ALLOC 2894 #ifdef NEW_GC
2933 s = alloc_lrecord_type (Lisp_String, &lrecord_string); 2895 s = alloc_lrecord_type (Lisp_String, &lrecord_string);
2934 mcpro (wrap_pointer_1 (s)); /* otherwise nocopy_strings get 2896 mcpro (wrap_pointer_1 (s)); /* otherwise nocopy_strings get
2935 collected and static data is tried to 2897 collected and static data is tried to
2936 be freed. */ 2898 be freed. */
2937 #else /* not MC_ALLOC */ 2899 #else /* not NEW_GC */
2938 /* Allocate the string header */ 2900 /* Allocate the string header */
2939 ALLOCATE_FIXED_TYPE (string, Lisp_String, s); 2901 ALLOCATE_FIXED_TYPE (string, Lisp_String, s);
2940 set_lheader_implementation (&s->u.lheader, &lrecord_string); 2902 set_lheader_implementation (&s->u.lheader, &lrecord_string);
2941 SET_C_READONLY_RECORD_HEADER (&s->u.lheader); 2903 SET_C_READONLY_RECORD_HEADER (&s->u.lheader);
2942 #endif /* not MC_ALLOC */ 2904 #endif /* not NEW_GC */
2943 /* Don't need to XSET_STRING_ASCII_BEGIN() here because it happens in 2905 /* Don't need to XSET_STRING_ASCII_BEGIN() here because it happens in
2944 init_string_ascii_begin(). */ 2906 init_string_ascii_begin(). */
2945 s->plist = Qnil; 2907 s->plist = Qnil;
2946 #ifdef NEW_GC 2908 #ifdef NEW_GC
2947 set_lispstringp_indirect (s); 2909 set_lispstringp_indirect (s);
2961 2923
2962 return val; 2924 return val;
2963 } 2925 }
2964 2926
2965 2927
2966 #ifndef MC_ALLOC 2928 #ifndef NEW_GC
2967 /************************************************************************/ 2929 /************************************************************************/
2968 /* lcrecord lists */ 2930 /* lcrecord lists */
2969 /************************************************************************/ 2931 /************************************************************************/
2970 2932
2971 /* Lcrecord lists are used to manage the allocation of particular 2933 /* Lcrecord lists are used to manage the allocation of particular
3169 3131
3170 assert (!EQ (all_lcrecord_lists[type], Qzero)); 3132 assert (!EQ (all_lcrecord_lists[type], Qzero));
3171 3133
3172 free_managed_lcrecord (all_lcrecord_lists[type], rec); 3134 free_managed_lcrecord (all_lcrecord_lists[type], rec);
3173 } 3135 }
3174 #endif /* not MC_ALLOC */ 3136 #endif /* not NEW_GC */
3175 3137
3176 3138
3177 DEFUN ("purecopy", Fpurecopy, 1, 1, 0, /* 3139 DEFUN ("purecopy", Fpurecopy, 1, 1, 0, /*
3178 Kept for compatibility, returns its argument. 3140 Kept for compatibility, returns its argument.
3179 Old: 3141 Old:
3348 3310
3349 3311
3350 3312
3351 3313
3352 3314
3353 #ifdef MC_ALLOC 3315 #ifdef NEW_GC
3354 static const struct memory_description mcpro_description_1[] = { 3316 static const struct memory_description mcpro_description_1[] = {
3355 { XD_END } 3317 { XD_END }
3356 }; 3318 };
3357 3319
3358 static const struct sized_memory_description mcpro_description = { 3320 static const struct sized_memory_description mcpro_description = {
3419 { 3381 {
3420 Dynarr_add (mcpros, varaddress); 3382 Dynarr_add (mcpros, varaddress);
3421 } 3383 }
3422 3384
3423 #endif /* not DEBUG_XEMACS */ 3385 #endif /* not DEBUG_XEMACS */
3424 #endif /* MC_ALLOC */ 3386 #endif /* NEW_GC */
3425 3387
3426 3388
3427 #ifndef MC_ALLOC 3389 #ifndef NEW_GC
3428 static int gc_count_num_short_string_in_use; 3390 static int gc_count_num_short_string_in_use;
3429 static Bytecount gc_count_string_total_size; 3391 static Bytecount gc_count_string_total_size;
3430 static Bytecount gc_count_short_string_total_size; 3392 static Bytecount gc_count_short_string_total_size;
3431 3393
3432 /* static int gc_count_total_records_used, gc_count_records_total_size; */ 3394 /* static int gc_count_total_records_used, gc_count_records_total_size; */
3468 lcrecord_stats[type_index].instances_in_use++; 3430 lcrecord_stats[type_index].instances_in_use++;
3469 lcrecord_stats[type_index].bytes_in_use += sz; 3431 lcrecord_stats[type_index].bytes_in_use += sz;
3470 } 3432 }
3471 } 3433 }
3472 } 3434 }
3473 #endif /* not MC_ALLOC */ 3435 #endif /* not NEW_GC */
3474 3436
3475 3437
3476 #ifndef MC_ALLOC 3438 #ifndef NEW_GC
3477 /* Free all unmarked records */ 3439 /* Free all unmarked records */
3478 static void 3440 static void
3479 sweep_lcrecords_1 (struct old_lcrecord_header **prev, int *used) 3441 sweep_lcrecords_1 (struct old_lcrecord_header **prev, int *used)
3480 { 3442 {
3481 struct old_lcrecord_header *header; 3443 struct old_lcrecord_header *header;
3667 #endif /* !ERROR_CHECK_GC */ 3629 #endif /* !ERROR_CHECK_GC */
3668 3630
3669 #define SWEEP_FIXED_TYPE_BLOCK(typename, obj_type) \ 3631 #define SWEEP_FIXED_TYPE_BLOCK(typename, obj_type) \
3670 SWEEP_FIXED_TYPE_BLOCK_1 (typename, obj_type, lheader) 3632 SWEEP_FIXED_TYPE_BLOCK_1 (typename, obj_type, lheader)
3671 3633
3672 #endif /* not MC_ALLOC */ 3634 #endif /* not NEW_GC */
3673 3635
3674 3636
3675 #ifndef MC_ALLOC 3637 #ifndef NEW_GC
3676 static void 3638 static void
3677 sweep_conses (void) 3639 sweep_conses (void)
3678 { 3640 {
3679 #define UNMARK_cons(ptr) UNMARK_RECORD_HEADER (&((ptr)->lheader)) 3641 #define UNMARK_cons(ptr) UNMARK_RECORD_HEADER (&((ptr)->lheader))
3680 #define ADDITIONAL_FREE_cons(ptr) 3642 #define ADDITIONAL_FREE_cons(ptr)
3681 3643
3682 SWEEP_FIXED_TYPE_BLOCK (cons, Lisp_Cons); 3644 SWEEP_FIXED_TYPE_BLOCK (cons, Lisp_Cons);
3683 } 3645 }
3684 #endif /* not MC_ALLOC */ 3646 #endif /* not NEW_GC */
3685 3647
3686 /* Explicitly free a cons cell. */ 3648 /* Explicitly free a cons cell. */
3687 void 3649 void
3688 free_cons (Lisp_Object cons) 3650 free_cons (Lisp_Object cons)
3689 { 3651 {
3690 #ifndef MC_ALLOC /* to avoid compiler warning */ 3652 #ifndef NEW_GC /* to avoid compiler warning */
3691 Lisp_Cons *ptr = XCONS (cons); 3653 Lisp_Cons *ptr = XCONS (cons);
3692 #endif /* MC_ALLOC */ 3654 #endif /* not NEW_GC */
3693 3655
3694 #ifdef ERROR_CHECK_GC 3656 #ifdef ERROR_CHECK_GC
3695 #ifdef MC_ALLOC 3657 #ifdef NEW_GC
3696 Lisp_Cons *ptr = XCONS (cons); 3658 Lisp_Cons *ptr = XCONS (cons);
3697 #endif /* MC_ALLOC */ 3659 #endif /* NEW_GC */
3698 /* If the CAR is not an int, then it will be a pointer, which will 3660 /* If the CAR is not an int, then it will be a pointer, which will
3699 always be four-byte aligned. If this cons cell has already been 3661 always be four-byte aligned. If this cons cell has already been
3700 placed on the free list, however, its car will probably contain 3662 placed on the free list, however, its car will probably contain
3701 a chain pointer to the next cons on the list, which has cleverly 3663 a chain pointer to the next cons on the list, which has cleverly
3702 had all its 0's and 1's inverted. This allows for a quick 3664 had all its 0's and 1's inverted. This allows for a quick
3707 well as a check in FREE_FIXED_TYPE(). */ 3669 well as a check in FREE_FIXED_TYPE(). */
3708 if (POINTER_TYPE_P (XTYPE (cons_car (ptr)))) 3670 if (POINTER_TYPE_P (XTYPE (cons_car (ptr))))
3709 ASSERT_VALID_POINTER (XPNTR (cons_car (ptr))); 3671 ASSERT_VALID_POINTER (XPNTR (cons_car (ptr)));
3710 #endif /* ERROR_CHECK_GC */ 3672 #endif /* ERROR_CHECK_GC */
3711 3673
3712 #ifdef MC_ALLOC 3674 #ifdef NEW_GC
3713 free_lrecord (cons); 3675 free_lrecord (cons);
3714 #else /* not MC_ALLOC */ 3676 #else /* not NEW_GC */
3715 FREE_FIXED_TYPE_WHEN_NOT_IN_GC (cons, Lisp_Cons, ptr); 3677 FREE_FIXED_TYPE_WHEN_NOT_IN_GC (cons, Lisp_Cons, ptr);
3716 #endif /* not MC_ALLOC */ 3678 #endif /* not NEW_GC */
3717 } 3679 }
3718 3680
3719 /* explicitly free a list. You **must make sure** that you have 3681 /* explicitly free a list. You **must make sure** that you have
3720 created all the cons cells that make up this list and that there 3682 created all the cons cells that make up this list and that there
3721 are no pointers to any of these cons cells anywhere else. If there 3683 are no pointers to any of these cons cells anywhere else. If there
3749 free_cons (XCAR (rest)); 3711 free_cons (XCAR (rest));
3750 free_cons (rest); 3712 free_cons (rest);
3751 } 3713 }
3752 } 3714 }
3753 3715
3754 #ifndef MC_ALLOC 3716 #ifndef NEW_GC
3755 static void 3717 static void
3756 sweep_compiled_functions (void) 3718 sweep_compiled_functions (void)
3757 { 3719 {
3758 #define UNMARK_compiled_function(ptr) UNMARK_RECORD_HEADER (&((ptr)->lheader)) 3720 #define UNMARK_compiled_function(ptr) UNMARK_RECORD_HEADER (&((ptr)->lheader))
3759 #define ADDITIONAL_FREE_compiled_function(ptr) \ 3721 #define ADDITIONAL_FREE_compiled_function(ptr) \
3828 #define UNMARK_event(ptr) UNMARK_RECORD_HEADER (&((ptr)->lheader)) 3790 #define UNMARK_event(ptr) UNMARK_RECORD_HEADER (&((ptr)->lheader))
3829 #define ADDITIONAL_FREE_event(ptr) 3791 #define ADDITIONAL_FREE_event(ptr)
3830 3792
3831 SWEEP_FIXED_TYPE_BLOCK (event, Lisp_Event); 3793 SWEEP_FIXED_TYPE_BLOCK (event, Lisp_Event);
3832 } 3794 }
3833 #endif /* not MC_ALLOC */ 3795 #endif /* not NEW_GC */
3834 3796
3835 #ifdef EVENT_DATA_AS_OBJECTS 3797 #ifdef EVENT_DATA_AS_OBJECTS
3836 3798
3837 #ifndef MC_ALLOC 3799 #ifndef NEW_GC
3838 static void 3800 static void
3839 sweep_key_data (void) 3801 sweep_key_data (void)
3840 { 3802 {
3841 #define UNMARK_key_data(ptr) UNMARK_RECORD_HEADER (&((ptr)->lheader)) 3803 #define UNMARK_key_data(ptr) UNMARK_RECORD_HEADER (&((ptr)->lheader))
3842 #define ADDITIONAL_FREE_key_data(ptr) 3804 #define ADDITIONAL_FREE_key_data(ptr)
3843 3805
3844 SWEEP_FIXED_TYPE_BLOCK (key_data, Lisp_Key_Data); 3806 SWEEP_FIXED_TYPE_BLOCK (key_data, Lisp_Key_Data);
3845 } 3807 }
3846 #endif /* not MC_ALLOC */ 3808 #endif /* not NEW_GC */
3847 3809
3848 void 3810 void
3849 free_key_data (Lisp_Object ptr) 3811 free_key_data (Lisp_Object ptr)
3850 { 3812 {
3851 #ifdef MC_ALLOC 3813 #ifdef NEW_GC
3852 free_lrecord (ptr); 3814 free_lrecord (ptr);
3853 #else /* not MC_ALLOC */ 3815 #else /* not NEW_GC */
3854 FREE_FIXED_TYPE_WHEN_NOT_IN_GC (key_data, Lisp_Key_Data, XKEY_DATA (ptr)); 3816 FREE_FIXED_TYPE_WHEN_NOT_IN_GC (key_data, Lisp_Key_Data, XKEY_DATA (ptr));
3855 #endif /* not MC_ALLOC */ 3817 #endif /* not NEW_GC */
3856 } 3818 }
3857 3819
3858 #ifndef MC_ALLOC 3820 #ifndef NEW_GC
3859 static void 3821 static void
3860 sweep_button_data (void) 3822 sweep_button_data (void)
3861 { 3823 {
3862 #define UNMARK_button_data(ptr) UNMARK_RECORD_HEADER (&((ptr)->lheader)) 3824 #define UNMARK_button_data(ptr) UNMARK_RECORD_HEADER (&((ptr)->lheader))
3863 #define ADDITIONAL_FREE_button_data(ptr) 3825 #define ADDITIONAL_FREE_button_data(ptr)
3864 3826
3865 SWEEP_FIXED_TYPE_BLOCK (button_data, Lisp_Button_Data); 3827 SWEEP_FIXED_TYPE_BLOCK (button_data, Lisp_Button_Data);
3866 } 3828 }
3867 #endif /* not MC_ALLOC */ 3829 #endif /* not NEW_GC */
3868 3830
3869 void 3831 void
3870 free_button_data (Lisp_Object ptr) 3832 free_button_data (Lisp_Object ptr)
3871 { 3833 {
3872 #ifdef MC_ALLOC 3834 #ifdef NEW_GC
3873 free_lrecord (ptr); 3835 free_lrecord (ptr);
3874 #else /* not MC_ALLOC */ 3836 #else /* not NEW_GC */
3875 FREE_FIXED_TYPE_WHEN_NOT_IN_GC (button_data, Lisp_Button_Data, XBUTTON_DATA (ptr)); 3837 FREE_FIXED_TYPE_WHEN_NOT_IN_GC (button_data, Lisp_Button_Data, XBUTTON_DATA (ptr));
3876 #endif /* not MC_ALLOC */ 3838 #endif /* not NEW_GC */
3877 } 3839 }
3878 3840
3879 #ifndef MC_ALLOC 3841 #ifndef NEW_GC
3880 static void 3842 static void
3881 sweep_motion_data (void) 3843 sweep_motion_data (void)
3882 { 3844 {
3883 #define UNMARK_motion_data(ptr) UNMARK_RECORD_HEADER (&((ptr)->lheader)) 3845 #define UNMARK_motion_data(ptr) UNMARK_RECORD_HEADER (&((ptr)->lheader))
3884 #define ADDITIONAL_FREE_motion_data(ptr) 3846 #define ADDITIONAL_FREE_motion_data(ptr)
3885 3847
3886 SWEEP_FIXED_TYPE_BLOCK (motion_data, Lisp_Motion_Data); 3848 SWEEP_FIXED_TYPE_BLOCK (motion_data, Lisp_Motion_Data);
3887 } 3849 }
3888 #endif /* not MC_ALLOC */ 3850 #endif /* not NEW_GC */
3889 3851
3890 void 3852 void
3891 free_motion_data (Lisp_Object ptr) 3853 free_motion_data (Lisp_Object ptr)
3892 { 3854 {
3893 #ifdef MC_ALLOC 3855 #ifdef NEW_GC
3894 free_lrecord (ptr); 3856 free_lrecord (ptr);
3895 #else /* not MC_ALLOC */ 3857 #else /* not NEW_GC */
3896 FREE_FIXED_TYPE_WHEN_NOT_IN_GC (motion_data, Lisp_Motion_Data, XMOTION_DATA (ptr)); 3858 FREE_FIXED_TYPE_WHEN_NOT_IN_GC (motion_data, Lisp_Motion_Data, XMOTION_DATA (ptr));
3897 #endif /* not MC_ALLOC */ 3859 #endif /* not NEW_GC */
3898 } 3860 }
3899 3861
3900 #ifndef MC_ALLOC 3862 #ifndef NEW_GC
3901 static void 3863 static void
3902 sweep_process_data (void) 3864 sweep_process_data (void)
3903 { 3865 {
3904 #define UNMARK_process_data(ptr) UNMARK_RECORD_HEADER (&((ptr)->lheader)) 3866 #define UNMARK_process_data(ptr) UNMARK_RECORD_HEADER (&((ptr)->lheader))
3905 #define ADDITIONAL_FREE_process_data(ptr) 3867 #define ADDITIONAL_FREE_process_data(ptr)
3906 3868
3907 SWEEP_FIXED_TYPE_BLOCK (process_data, Lisp_Process_Data); 3869 SWEEP_FIXED_TYPE_BLOCK (process_data, Lisp_Process_Data);
3908 } 3870 }
3909 #endif /* not MC_ALLOC */ 3871 #endif /* not NEW_GC */
3910 3872
3911 void 3873 void
3912 free_process_data (Lisp_Object ptr) 3874 free_process_data (Lisp_Object ptr)
3913 { 3875 {
3914 #ifdef MC_ALLOC 3876 #ifdef NEW_GC
3915 free_lrecord (ptr); 3877 free_lrecord (ptr);
3916 #else /* not MC_ALLOC */ 3878 #else /* not NEW_GC */
3917 FREE_FIXED_TYPE_WHEN_NOT_IN_GC (process_data, Lisp_Process_Data, XPROCESS_DATA (ptr)); 3879 FREE_FIXED_TYPE_WHEN_NOT_IN_GC (process_data, Lisp_Process_Data, XPROCESS_DATA (ptr));
3918 #endif /* not MC_ALLOC */ 3880 #endif /* not NEW_GC */
3919 } 3881 }
3920 3882
3921 #ifndef MC_ALLOC 3883 #ifndef NEW_GC
3922 static void 3884 static void
3923 sweep_timeout_data (void) 3885 sweep_timeout_data (void)
3924 { 3886 {
3925 #define UNMARK_timeout_data(ptr) UNMARK_RECORD_HEADER (&((ptr)->lheader)) 3887 #define UNMARK_timeout_data(ptr) UNMARK_RECORD_HEADER (&((ptr)->lheader))
3926 #define ADDITIONAL_FREE_timeout_data(ptr) 3888 #define ADDITIONAL_FREE_timeout_data(ptr)
3927 3889
3928 SWEEP_FIXED_TYPE_BLOCK (timeout_data, Lisp_Timeout_Data); 3890 SWEEP_FIXED_TYPE_BLOCK (timeout_data, Lisp_Timeout_Data);
3929 } 3891 }
3930 #endif /* not MC_ALLOC */ 3892 #endif /* not NEW_GC */
3931 3893
3932 void 3894 void
3933 free_timeout_data (Lisp_Object ptr) 3895 free_timeout_data (Lisp_Object ptr)
3934 { 3896 {
3935 #ifdef MC_ALLOC 3897 #ifdef NEW_GC
3936 free_lrecord (ptr); 3898 free_lrecord (ptr);
3937 #else /* not MC_ALLOC */ 3899 #else /* not NEW_GC */
3938 FREE_FIXED_TYPE_WHEN_NOT_IN_GC (timeout_data, Lisp_Timeout_Data, XTIMEOUT_DATA (ptr)); 3900 FREE_FIXED_TYPE_WHEN_NOT_IN_GC (timeout_data, Lisp_Timeout_Data, XTIMEOUT_DATA (ptr));
3939 #endif /* not MC_ALLOC */ 3901 #endif /* not NEW_GC */
3940 } 3902 }
3941 3903
3942 #ifndef MC_ALLOC 3904 #ifndef NEW_GC
3943 static void 3905 static void
3944 sweep_magic_data (void) 3906 sweep_magic_data (void)
3945 { 3907 {
3946 #define UNMARK_magic_data(ptr) UNMARK_RECORD_HEADER (&((ptr)->lheader)) 3908 #define UNMARK_magic_data(ptr) UNMARK_RECORD_HEADER (&((ptr)->lheader))
3947 #define ADDITIONAL_FREE_magic_data(ptr) 3909 #define ADDITIONAL_FREE_magic_data(ptr)
3948 3910
3949 SWEEP_FIXED_TYPE_BLOCK (magic_data, Lisp_Magic_Data); 3911 SWEEP_FIXED_TYPE_BLOCK (magic_data, Lisp_Magic_Data);
3950 } 3912 }
3951 #endif /* not MC_ALLOC */ 3913 #endif /* not NEW_GC */
3952 3914
3953 void 3915 void
3954 free_magic_data (Lisp_Object ptr) 3916 free_magic_data (Lisp_Object ptr)
3955 { 3917 {
3956 #ifdef MC_ALLOC 3918 #ifdef NEW_GC
3957 free_lrecord (ptr); 3919 free_lrecord (ptr);
3958 #else /* not MC_ALLOC */ 3920 #else /* not NEW_GC */
3959 FREE_FIXED_TYPE_WHEN_NOT_IN_GC (magic_data, Lisp_Magic_Data, XMAGIC_DATA (ptr)); 3921 FREE_FIXED_TYPE_WHEN_NOT_IN_GC (magic_data, Lisp_Magic_Data, XMAGIC_DATA (ptr));
3960 #endif /* not MC_ALLOC */ 3922 #endif /* not NEW_GC */
3961 } 3923 }
3962 3924
3963 #ifndef MC_ALLOC 3925 #ifndef NEW_GC
3964 static void 3926 static void
3965 sweep_magic_eval_data (void) 3927 sweep_magic_eval_data (void)
3966 { 3928 {
3967 #define UNMARK_magic_eval_data(ptr) UNMARK_RECORD_HEADER (&((ptr)->lheader)) 3929 #define UNMARK_magic_eval_data(ptr) UNMARK_RECORD_HEADER (&((ptr)->lheader))
3968 #define ADDITIONAL_FREE_magic_eval_data(ptr) 3930 #define ADDITIONAL_FREE_magic_eval_data(ptr)
3969 3931
3970 SWEEP_FIXED_TYPE_BLOCK (magic_eval_data, Lisp_Magic_Eval_Data); 3932 SWEEP_FIXED_TYPE_BLOCK (magic_eval_data, Lisp_Magic_Eval_Data);
3971 } 3933 }
3972 #endif /* not MC_ALLOC */ 3934 #endif /* not NEW_GC */
3973 3935
3974 void 3936 void
3975 free_magic_eval_data (Lisp_Object ptr) 3937 free_magic_eval_data (Lisp_Object ptr)
3976 { 3938 {
3977 #ifdef MC_ALLOC 3939 #ifdef NEW_GC
3978 free_lrecord (ptr); 3940 free_lrecord (ptr);
3979 #else /* not MC_ALLOC */ 3941 #else /* not NEW_GC */
3980 FREE_FIXED_TYPE_WHEN_NOT_IN_GC (magic_eval_data, Lisp_Magic_Eval_Data, XMAGIC_EVAL_DATA (ptr)); 3942 FREE_FIXED_TYPE_WHEN_NOT_IN_GC (magic_eval_data, Lisp_Magic_Eval_Data, XMAGIC_EVAL_DATA (ptr));
3981 #endif /* not MC_ALLOC */ 3943 #endif /* not NEW_GC */
3982 } 3944 }
3983 3945
3984 #ifndef MC_ALLOC 3946 #ifndef NEW_GC
3985 static void 3947 static void
3986 sweep_eval_data (void) 3948 sweep_eval_data (void)
3987 { 3949 {
3988 #define UNMARK_eval_data(ptr) UNMARK_RECORD_HEADER (&((ptr)->lheader)) 3950 #define UNMARK_eval_data(ptr) UNMARK_RECORD_HEADER (&((ptr)->lheader))
3989 #define ADDITIONAL_FREE_eval_data(ptr) 3951 #define ADDITIONAL_FREE_eval_data(ptr)
3990 3952
3991 SWEEP_FIXED_TYPE_BLOCK (eval_data, Lisp_Eval_Data); 3953 SWEEP_FIXED_TYPE_BLOCK (eval_data, Lisp_Eval_Data);
3992 } 3954 }
3993 #endif /* not MC_ALLOC */ 3955 #endif /* not NEW_GC */
3994 3956
3995 void 3957 void
3996 free_eval_data (Lisp_Object ptr) 3958 free_eval_data (Lisp_Object ptr)
3997 { 3959 {
3998 #ifdef MC_ALLOC 3960 #ifdef NEW_GC
3999 free_lrecord (ptr); 3961 free_lrecord (ptr);
4000 #else /* not MC_ALLOC */ 3962 #else /* not NEW_GC */
4001 FREE_FIXED_TYPE_WHEN_NOT_IN_GC (eval_data, Lisp_Eval_Data, XEVAL_DATA (ptr)); 3963 FREE_FIXED_TYPE_WHEN_NOT_IN_GC (eval_data, Lisp_Eval_Data, XEVAL_DATA (ptr));
4002 #endif /* not MC_ALLOC */ 3964 #endif /* not NEW_GC */
4003 } 3965 }
4004 3966
4005 #ifndef MC_ALLOC 3967 #ifndef NEW_GC
4006 static void 3968 static void
4007 sweep_misc_user_data (void) 3969 sweep_misc_user_data (void)
4008 { 3970 {
4009 #define UNMARK_misc_user_data(ptr) UNMARK_RECORD_HEADER (&((ptr)->lheader)) 3971 #define UNMARK_misc_user_data(ptr) UNMARK_RECORD_HEADER (&((ptr)->lheader))
4010 #define ADDITIONAL_FREE_misc_user_data(ptr) 3972 #define ADDITIONAL_FREE_misc_user_data(ptr)
4011 3973
4012 SWEEP_FIXED_TYPE_BLOCK (misc_user_data, Lisp_Misc_User_Data); 3974 SWEEP_FIXED_TYPE_BLOCK (misc_user_data, Lisp_Misc_User_Data);
4013 } 3975 }
4014 #endif /* not MC_ALLOC */ 3976 #endif /* not NEW_GC */
4015 3977
4016 void 3978 void
4017 free_misc_user_data (Lisp_Object ptr) 3979 free_misc_user_data (Lisp_Object ptr)
4018 { 3980 {
4019 #ifdef MC_ALLOC 3981 #ifdef NEW_GC
4020 free_lrecord (ptr); 3982 free_lrecord (ptr);
4021 #else /* not MC_ALLOC */ 3983 #else /* not NEW_GC */
4022 FREE_FIXED_TYPE_WHEN_NOT_IN_GC (misc_user_data, Lisp_Misc_User_Data, XMISC_USER_DATA (ptr)); 3984 FREE_FIXED_TYPE_WHEN_NOT_IN_GC (misc_user_data, Lisp_Misc_User_Data, XMISC_USER_DATA (ptr));
4023 #endif /* not MC_ALLOC */ 3985 #endif /* not NEW_GC */
4024 } 3986 }
4025 3987
4026 #endif /* EVENT_DATA_AS_OBJECTS */ 3988 #endif /* EVENT_DATA_AS_OBJECTS */
4027 3989
4028 #ifndef MC_ALLOC 3990 #ifndef NEW_GC
4029 static void 3991 static void
4030 sweep_markers (void) 3992 sweep_markers (void)
4031 { 3993 {
4032 #define UNMARK_marker(ptr) UNMARK_RECORD_HEADER (&((ptr)->lheader)) 3994 #define UNMARK_marker(ptr) UNMARK_RECORD_HEADER (&((ptr)->lheader))
4033 #define ADDITIONAL_FREE_marker(ptr) \ 3995 #define ADDITIONAL_FREE_marker(ptr) \
4036 unchain_marker (tem); \ 3998 unchain_marker (tem); \
4037 } while (0) 3999 } while (0)
4038 4000
4039 SWEEP_FIXED_TYPE_BLOCK (marker, Lisp_Marker); 4001 SWEEP_FIXED_TYPE_BLOCK (marker, Lisp_Marker);
4040 } 4002 }
4041 #endif /* not MC_ALLOC */ 4003 #endif /* not NEW_GC */
4042 4004
4043 /* Explicitly free a marker. */ 4005 /* Explicitly free a marker. */
4044 void 4006 void
4045 free_marker (Lisp_Object ptr) 4007 free_marker (Lisp_Object ptr)
4046 { 4008 {
4047 #ifdef MC_ALLOC 4009 #ifdef NEW_GC
4048 free_lrecord (ptr); 4010 free_lrecord (ptr);
4049 #else /* not MC_ALLOC */ 4011 #else /* not NEW_GC */
4050 FREE_FIXED_TYPE_WHEN_NOT_IN_GC (marker, Lisp_Marker, XMARKER (ptr)); 4012 FREE_FIXED_TYPE_WHEN_NOT_IN_GC (marker, Lisp_Marker, XMARKER (ptr));
4051 #endif /* not MC_ALLOC */ 4013 #endif /* not NEW_GC */
4052 } 4014 }
4053 4015
4054 4016
4055 #if defined (MULE) && defined (VERIFY_STRING_CHARS_INTEGRITY) 4017 #if defined (MULE) && defined (VERIFY_STRING_CHARS_INTEGRITY)
4056 4018
4199 current_string_chars_block->next = 0; 4161 current_string_chars_block->next = 0;
4200 } 4162 }
4201 } 4163 }
4202 #endif /* not NEW_GC */ 4164 #endif /* not NEW_GC */
4203 4165
4204 #ifndef MC_ALLOC 4166 #ifndef NEW_GC
4205 #if 1 /* Hack to debug missing purecopy's */ 4167 #if 1 /* Hack to debug missing purecopy's */
4206 static int debug_string_purity; 4168 static int debug_string_purity;
4207 4169
4208 static void 4170 static void
4209 debug_string_purity_print (Lisp_Object p) 4171 debug_string_purity_print (Lisp_Object p)
4222 stderr_out ("%c", ch); 4184 stderr_out ("%c", ch);
4223 } 4185 }
4224 stderr_out ("\"\n"); 4186 stderr_out ("\"\n");
4225 } 4187 }
4226 #endif /* 1 */ 4188 #endif /* 1 */
4227 #endif /* not MC_ALLOC */ 4189 #endif /* not NEW_GC */
4228 4190
4229 #ifndef MC_ALLOC 4191 #ifndef NEW_GC
4230 static void 4192 static void
4231 sweep_strings (void) 4193 sweep_strings (void)
4232 { 4194 {
4233 int num_small_used = 0; 4195 int num_small_used = 0;
4234 Bytecount num_small_bytes = 0, num_bytes = 0; 4196 Bytecount num_small_bytes = 0, num_bytes = 0;
4257 4219
4258 gc_count_num_short_string_in_use = num_small_used; 4220 gc_count_num_short_string_in_use = num_small_used;
4259 gc_count_string_total_size = num_bytes; 4221 gc_count_string_total_size = num_bytes;
4260 gc_count_short_string_total_size = num_small_bytes; 4222 gc_count_short_string_total_size = num_small_bytes;
4261 } 4223 }
4262 #endif /* not MC_ALLOC */ 4224 #endif /* not NEW_GC */
4263 4225
4264 #ifndef NEW_GC 4226 #ifndef NEW_GC
4265 void 4227 void
4266 gc_sweep_1 (void) 4228 gc_sweep_1 (void)
4267 { 4229 {
4268 #ifdef MC_ALLOC
4269 compact_string_chars ();
4270 mc_finalize ();
4271 mc_sweep ();
4272 #else /* not MC_ALLOC */
4273 /* Free all unmarked records. Do this at the very beginning, 4230 /* Free all unmarked records. Do this at the very beginning,
4274 before anything else, so that the finalize methods can safely 4231 before anything else, so that the finalize methods can safely
4275 examine items in the objects. sweep_lcrecords_1() makes 4232 examine items in the objects. sweep_lcrecords_1() makes
4276 sure to call all the finalize methods *before* freeing anything, 4233 sure to call all the finalize methods *before* freeing anything,
4277 to complete the safety. */ 4234 to complete the safety. */
4342 sweep_magic_data (); 4299 sweep_magic_data ();
4343 sweep_magic_eval_data (); 4300 sweep_magic_eval_data ();
4344 sweep_eval_data (); 4301 sweep_eval_data ();
4345 sweep_misc_user_data (); 4302 sweep_misc_user_data ();
4346 #endif /* EVENT_DATA_AS_OBJECTS */ 4303 #endif /* EVENT_DATA_AS_OBJECTS */
4347 #endif /* not MC_ALLOC */ 4304 #endif /* not NEW_GC */
4348 4305
4349 #ifndef MC_ALLOC 4306 #ifndef NEW_GC
4350 #ifdef PDUMP 4307 #ifdef PDUMP
4351 pdump_objects_unmark (); 4308 pdump_objects_unmark ();
4352 #endif 4309 #endif
4353 #endif /* not MC_ALLOC */
4354 } 4310 }
4355 #endif /* not NEW_GC */ 4311 #endif /* not NEW_GC */
4356 4312
4357 /* Clearing for disksave. */ 4313 /* Clearing for disksave. */
4358 4314
4438 { 4394 {
4439 Lisp_Object pl = Qnil; 4395 Lisp_Object pl = Qnil;
4440 int i; 4396 int i;
4441 EMACS_INT tgu_val = 0; 4397 EMACS_INT tgu_val = 0;
4442 4398
4443 #ifdef MC_ALLOC 4399 #ifdef NEW_GC
4444 4400
4445 for (i = 0; i < (countof (lrecord_implementations_table) 4401 for (i = 0; i < (countof (lrecord_implementations_table)
4446 + MODULE_DEFINABLE_TYPE_COUNT); i++) 4402 + MODULE_DEFINABLE_TYPE_COUNT); i++)
4447 { 4403 {
4448 if (lrecord_stats[i].instances_in_use != 0) 4404 if (lrecord_stats[i].instances_in_use != 0)
4473 sprintf (buf, "%ss-used", name); 4429 sprintf (buf, "%ss-used", name);
4474 pl = gc_plist_hack (buf, lrecord_stats[i].instances_in_use, pl); 4430 pl = gc_plist_hack (buf, lrecord_stats[i].instances_in_use, pl);
4475 } 4431 }
4476 } 4432 }
4477 4433
4478 #else /* not MC_ALLOC */ 4434 #else /* not NEW_GC */
4479 4435
4480 #define HACK_O_MATIC(type, name, pl) do { \ 4436 #define HACK_O_MATIC(type, name, pl) do { \
4481 EMACS_INT s = 0; \ 4437 EMACS_INT s = 0; \
4482 struct type##_block *x = current_##type##_block; \ 4438 struct type##_block *x = current_##type##_block; \
4483 while (x) { s += sizeof (*x) + MALLOC_OVERHEAD; x = x->prev; } \ 4439 while (x) { s += sizeof (*x) + MALLOC_OVERHEAD; x = x->prev; } \
4575 pl = gc_plist_hack ("conses-free", gc_count_num_cons_freelist, pl); 4531 pl = gc_plist_hack ("conses-free", gc_count_num_cons_freelist, pl);
4576 pl = gc_plist_hack ("conses-used", gc_count_num_cons_in_use, pl); 4532 pl = gc_plist_hack ("conses-used", gc_count_num_cons_in_use, pl);
4577 4533
4578 #undef HACK_O_MATIC 4534 #undef HACK_O_MATIC
4579 4535
4580 #endif /* MC_ALLOC */ 4536 #endif /* NEW_GC */
4581 4537
4582 if (set_total_gc_usage) 4538 if (set_total_gc_usage)
4583 { 4539 {
4584 total_gc_usage = tgu_val; 4540 total_gc_usage = tgu_val;
4585 total_gc_usage_set = 1; 4541 total_gc_usage_set = 1;
4623 /* This will get set to 1, and total_gc_usage computed, as part of the 4579 /* This will get set to 1, and total_gc_usage computed, as part of the
4624 call to object_memory_usage_stats() -- if ALLOC_TYPE_STATS is enabled. */ 4580 call to object_memory_usage_stats() -- if ALLOC_TYPE_STATS is enabled. */
4625 total_gc_usage_set = 0; 4581 total_gc_usage_set = 0;
4626 #ifdef ALLOC_TYPE_STATS 4582 #ifdef ALLOC_TYPE_STATS
4627 /* The things we do for backwards-compatibility */ 4583 /* The things we do for backwards-compatibility */
4628 #ifdef MC_ALLOC 4584 #ifdef NEW_GC
4629 return 4585 return
4630 list6 4586 list6
4631 (Fcons (make_int (lrecord_stats[lrecord_type_cons].instances_in_use), 4587 (Fcons (make_int (lrecord_stats[lrecord_type_cons].instances_in_use),
4632 make_int (lrecord_stats[lrecord_type_cons] 4588 make_int (lrecord_stats[lrecord_type_cons]
4633 .bytes_in_use_including_overhead)), 4589 .bytes_in_use_including_overhead)),
4640 make_int (lrecord_stats[lrecord_type_string] 4596 make_int (lrecord_stats[lrecord_type_string]
4641 .bytes_in_use_including_overhead), 4597 .bytes_in_use_including_overhead),
4642 make_int (lrecord_stats[lrecord_type_vector] 4598 make_int (lrecord_stats[lrecord_type_vector]
4643 .bytes_in_use_including_overhead), 4599 .bytes_in_use_including_overhead),
4644 object_memory_usage_stats (1)); 4600 object_memory_usage_stats (1));
4645 #else /* not MC_ALLOC */ 4601 #else /* not NEW_GC */
4646 return 4602 return
4647 list6 (Fcons (make_int (gc_count_num_cons_in_use), 4603 list6 (Fcons (make_int (gc_count_num_cons_in_use),
4648 make_int (gc_count_num_cons_freelist)), 4604 make_int (gc_count_num_cons_freelist)),
4649 Fcons (make_int (gc_count_num_symbol_in_use), 4605 Fcons (make_int (gc_count_num_symbol_in_use),
4650 make_int (gc_count_num_symbol_freelist)), 4606 make_int (gc_count_num_symbol_freelist)),
4652 make_int (gc_count_num_marker_freelist)), 4608 make_int (gc_count_num_marker_freelist)),
4653 make_int (gc_count_string_total_size), 4609 make_int (gc_count_string_total_size),
4654 make_int (lcrecord_stats[lrecord_type_vector].bytes_in_use + 4610 make_int (lcrecord_stats[lrecord_type_vector].bytes_in_use +
4655 lcrecord_stats[lrecord_type_vector].bytes_freed), 4611 lcrecord_stats[lrecord_type_vector].bytes_freed),
4656 object_memory_usage_stats (1)); 4612 object_memory_usage_stats (1));
4657 #endif /* not MC_ALLOC */ 4613 #endif /* not NEW_GC */
4658 #else /* not ALLOC_TYPE_STATS */ 4614 #else /* not ALLOC_TYPE_STATS */
4659 return Qnil; 4615 return Qnil;
4660 #endif /* ALLOC_TYPE_STATS */ 4616 #endif /* ALLOC_TYPE_STATS */
4661 } 4617 }
4662 4618
4847 stats->malloc_overhead += claimed_size - orig_claimed_size; 4803 stats->malloc_overhead += claimed_size - orig_claimed_size;
4848 } 4804 }
4849 return claimed_size; 4805 return claimed_size;
4850 } 4806 }
4851 4807
4852 #ifndef MC_ALLOC 4808 #ifndef NEW_GC
4853 Bytecount 4809 Bytecount
4854 fixed_type_block_overhead (Bytecount size) 4810 fixed_type_block_overhead (Bytecount size)
4855 { 4811 {
4856 Bytecount per_block = TYPE_ALLOC_SIZE (cons, unsigned char); 4812 Bytecount per_block = TYPE_ALLOC_SIZE (cons, unsigned char);
4857 Bytecount overhead = 0; 4813 Bytecount overhead = 0;
4863 } 4819 }
4864 if (rand () % per_block < size) 4820 if (rand () % per_block < size)
4865 overhead += sizeof (void *) + per_block - storage_size; 4821 overhead += sizeof (void *) + per_block - storage_size;
4866 return overhead; 4822 return overhead;
4867 } 4823 }
4868 #endif /* not MC_ALLOC */ 4824 #endif /* not NEW_GC */
4869 #endif /* MEMORY_USAGE_STATS */ 4825 #endif /* MEMORY_USAGE_STATS */
4870 4826
4871 4827
4872 /* Initialization */ 4828 /* Initialization */
4873 static void 4829 static void
4881 /* C guarantees that Qnull_pointer will be initialized to all 0 bits, 4837 /* C guarantees that Qnull_pointer will be initialized to all 0 bits,
4882 so the following is actually a no-op. */ 4838 so the following is actually a no-op. */
4883 Qnull_pointer = wrap_pointer_1 (0); 4839 Qnull_pointer = wrap_pointer_1 (0);
4884 #endif 4840 #endif
4885 4841
4886 #ifndef MC_ALLOC 4842 #ifndef NEW_GC
4887 breathing_space = 0; 4843 breathing_space = 0;
4888 #endif /* not MC_ALLOC */
4889 #ifndef MC_ALLOC
4890 all_lcrecords = 0; 4844 all_lcrecords = 0;
4891 #endif /* not MC_ALLOC */ 4845 #endif /* not NEW_GC */
4892 ignore_malloc_warnings = 1; 4846 ignore_malloc_warnings = 1;
4893 #ifdef DOUG_LEA_MALLOC 4847 #ifdef DOUG_LEA_MALLOC
4894 mallopt (M_TRIM_THRESHOLD, 128*1024); /* trim threshold */ 4848 mallopt (M_TRIM_THRESHOLD, 128*1024); /* trim threshold */
4895 mallopt (M_MMAP_THRESHOLD, 64*1024); /* mmap threshold */ 4849 mallopt (M_MMAP_THRESHOLD, 64*1024); /* mmap threshold */
4896 #if 0 /* Moved to emacs.c */ 4850 #if 0 /* Moved to emacs.c */
4897 mallopt (M_MMAP_MAX, 64); /* max. number of mmap'ed areas */ 4851 mallopt (M_MMAP_MAX, 64); /* max. number of mmap'ed areas */
4898 #endif 4852 #endif
4899 #endif 4853 #endif
4900 #ifndef NEW_GC 4854 #ifndef NEW_GC
4901 init_string_chars_alloc (); 4855 init_string_chars_alloc ();
4902 #endif /* not NEW_GC */
4903 #ifndef MC_ALLOC
4904 init_string_alloc (); 4856 init_string_alloc ();
4905 init_string_chars_alloc (); 4857 init_string_chars_alloc ();
4906 init_cons_alloc (); 4858 init_cons_alloc ();
4907 init_symbol_alloc (); 4859 init_symbol_alloc ();
4908 init_compiled_function_alloc (); 4860 init_compiled_function_alloc ();
4928 init_magic_data_alloc (); 4880 init_magic_data_alloc ();
4929 init_magic_eval_data_alloc (); 4881 init_magic_eval_data_alloc ();
4930 init_eval_data_alloc (); 4882 init_eval_data_alloc ();
4931 init_misc_user_data_alloc (); 4883 init_misc_user_data_alloc ();
4932 #endif /* EVENT_DATA_AS_OBJECTS */ 4884 #endif /* EVENT_DATA_AS_OBJECTS */
4933 #endif /* not MC_ALLOC */ 4885 #endif /* not NEW_GC */
4934 4886
4935 ignore_malloc_warnings = 0; 4887 ignore_malloc_warnings = 0;
4936 4888
4937 if (staticpros_nodump) 4889 if (staticpros_nodump)
4938 Dynarr_free (staticpros_nodump); 4890 Dynarr_free (staticpros_nodump);
4943 Dynarr_free (staticpro_nodump_names); 4895 Dynarr_free (staticpro_nodump_names);
4944 staticpro_nodump_names = Dynarr_new2 (char_ptr_dynarr, char *); 4896 staticpro_nodump_names = Dynarr_new2 (char_ptr_dynarr, char *);
4945 Dynarr_resize (staticpro_nodump_names, 100); /* ditto */ 4897 Dynarr_resize (staticpro_nodump_names, 100); /* ditto */
4946 #endif 4898 #endif
4947 4899
4948 #ifdef MC_ALLOC 4900 #ifdef NEW_GC
4949 mcpros = Dynarr_new2 (Lisp_Object_dynarr, Lisp_Object); 4901 mcpros = Dynarr_new2 (Lisp_Object_dynarr, Lisp_Object);
4950 Dynarr_resize (mcpros, 1410); /* merely a small optimization */ 4902 Dynarr_resize (mcpros, 1410); /* merely a small optimization */
4951 dump_add_root_block_ptr (&mcpros, &mcpros_description); 4903 dump_add_root_block_ptr (&mcpros, &mcpros_description);
4952 #ifdef DEBUG_XEMACS 4904 #ifdef DEBUG_XEMACS
4953 mcpro_names = Dynarr_new2 (char_ptr_dynarr, char *); 4905 mcpro_names = Dynarr_new2 (char_ptr_dynarr, char *);
4954 Dynarr_resize (mcpro_names, 1410); /* merely a small optimization */ 4906 Dynarr_resize (mcpro_names, 1410); /* merely a small optimization */
4955 dump_add_root_block_ptr (&mcpro_names, &mcpro_names_description); 4907 dump_add_root_block_ptr (&mcpro_names, &mcpro_names_description);
4956 #endif 4908 #endif
4957 #endif /* MC_ALLOC */ 4909 #endif /* NEW_GC */
4958 4910
4959 consing_since_gc = 0; 4911 consing_since_gc = 0;
4960 need_to_check_c_alloca = 0; 4912 need_to_check_c_alloca = 0;
4961 funcall_allocation_flag = 0; 4913 funcall_allocation_flag = 0;
4962 funcall_alloca_count = 0; 4914 funcall_alloca_count = 0;
4963 4915
4964 lrecord_uid_counter = 259; 4916 lrecord_uid_counter = 259;
4965 #ifndef MC_ALLOC 4917 #ifndef NEW_GC
4966 debug_string_purity = 0; 4918 debug_string_purity = 0;
4967 #endif /* not MC_ALLOC */ 4919 #endif /* not NEW_GC */
4968 4920
4969 #ifdef ERROR_CHECK_TYPES 4921 #ifdef ERROR_CHECK_TYPES
4970 ERROR_ME.really_unlikely_name_to_have_accidentally_in_a_non_errb_structure = 4922 ERROR_ME.really_unlikely_name_to_have_accidentally_in_a_non_errb_structure =
4971 666; 4923 666;
4972 ERROR_ME_NOT. 4924 ERROR_ME_NOT.
4978 really_unlikely_name_to_have_accidentally_in_a_non_errb_structure = 4930 really_unlikely_name_to_have_accidentally_in_a_non_errb_structure =
4979 8675309; 4931 8675309;
4980 #endif /* ERROR_CHECK_TYPES */ 4932 #endif /* ERROR_CHECK_TYPES */
4981 } 4933 }
4982 4934
4983 #ifndef MC_ALLOC 4935 #ifndef NEW_GC
4984 static void 4936 static void
4985 init_lcrecord_lists (void) 4937 init_lcrecord_lists (void)
4986 { 4938 {
4987 int i; 4939 int i;
4988 4940
4990 { 4942 {
4991 all_lcrecord_lists[i] = Qzero; /* Qnil not yet set */ 4943 all_lcrecord_lists[i] = Qzero; /* Qnil not yet set */
4992 staticpro_nodump (&all_lcrecord_lists[i]); 4944 staticpro_nodump (&all_lcrecord_lists[i]);
4993 } 4945 }
4994 } 4946 }
4995 #endif /* not MC_ALLOC */ 4947 #endif /* not NEW_GC */
4996 4948
4997 void 4949 void
4998 init_alloc_early (void) 4950 init_alloc_early (void)
4999 { 4951 {
5000 #if defined (__cplusplus) && defined (ERROR_CHECK_GC) 4952 #if defined (__cplusplus) && defined (ERROR_CHECK_GC)
5011 4963
5012 void 4964 void
5013 reinit_alloc_early (void) 4965 reinit_alloc_early (void)
5014 { 4966 {
5015 common_init_alloc_early (); 4967 common_init_alloc_early ();
5016 #ifndef MC_ALLOC 4968 #ifndef NEW_GC
5017 init_lcrecord_lists (); 4969 init_lcrecord_lists ();
5018 #endif /* not MC_ALLOC */ 4970 #endif /* not NEW_GC */
5019 } 4971 }
5020 4972
5021 void 4973 void
5022 init_alloc_once_early (void) 4974 init_alloc_once_early (void)
5023 { 4975 {
5034 INIT_LRECORD_IMPLEMENTATION (string); 4986 INIT_LRECORD_IMPLEMENTATION (string);
5035 #ifdef NEW_GC 4987 #ifdef NEW_GC
5036 INIT_LRECORD_IMPLEMENTATION (string_indirect_data); 4988 INIT_LRECORD_IMPLEMENTATION (string_indirect_data);
5037 INIT_LRECORD_IMPLEMENTATION (string_direct_data); 4989 INIT_LRECORD_IMPLEMENTATION (string_direct_data);
5038 #endif /* NEW_GC */ 4990 #endif /* NEW_GC */
5039 #ifndef MC_ALLOC 4991 #ifndef NEW_GC
5040 INIT_LRECORD_IMPLEMENTATION (lcrecord_list); 4992 INIT_LRECORD_IMPLEMENTATION (lcrecord_list);
5041 INIT_LRECORD_IMPLEMENTATION (free); 4993 INIT_LRECORD_IMPLEMENTATION (free);
5042 #endif /* not MC_ALLOC */ 4994 #endif /* not NEW_GC */
5043 4995
5044 staticpros = Dynarr_new2 (Lisp_Object_ptr_dynarr, Lisp_Object *); 4996 staticpros = Dynarr_new2 (Lisp_Object_ptr_dynarr, Lisp_Object *);
5045 Dynarr_resize (staticpros, 1410); /* merely a small optimization */ 4997 Dynarr_resize (staticpros, 1410); /* merely a small optimization */
5046 dump_add_root_block_ptr (&staticpros, &staticpros_description); 4998 dump_add_root_block_ptr (&staticpros, &staticpros_description);
5047 #ifdef DEBUG_XEMACS 4999 #ifdef DEBUG_XEMACS
5048 staticpro_names = Dynarr_new2 (char_ptr_dynarr, char *); 5000 staticpro_names = Dynarr_new2 (char_ptr_dynarr, char *);
5049 Dynarr_resize (staticpro_names, 1410); /* merely a small optimization */ 5001 Dynarr_resize (staticpro_names, 1410); /* merely a small optimization */
5050 dump_add_root_block_ptr (&staticpro_names, &staticpro_names_description); 5002 dump_add_root_block_ptr (&staticpro_names, &staticpro_names_description);
5051 #endif 5003 #endif
5052 5004
5053 #ifdef MC_ALLOC 5005 #ifdef NEW_GC
5054 mcpros = Dynarr_new2 (Lisp_Object_dynarr, Lisp_Object); 5006 mcpros = Dynarr_new2 (Lisp_Object_dynarr, Lisp_Object);
5055 Dynarr_resize (mcpros, 1410); /* merely a small optimization */ 5007 Dynarr_resize (mcpros, 1410); /* merely a small optimization */
5056 dump_add_root_block_ptr (&mcpros, &mcpros_description); 5008 dump_add_root_block_ptr (&mcpros, &mcpros_description);
5057 #ifdef DEBUG_XEMACS 5009 #ifdef DEBUG_XEMACS
5058 mcpro_names = Dynarr_new2 (char_ptr_dynarr, char *); 5010 mcpro_names = Dynarr_new2 (char_ptr_dynarr, char *);
5059 Dynarr_resize (mcpro_names, 1410); /* merely a small optimization */ 5011 Dynarr_resize (mcpro_names, 1410); /* merely a small optimization */
5060 dump_add_root_block_ptr (&mcpro_names, &mcpro_names_description); 5012 dump_add_root_block_ptr (&mcpro_names, &mcpro_names_description);
5061 #endif 5013 #endif
5062 #endif /* MC_ALLOC */ 5014 #else /* not NEW_GC */
5063
5064 #ifndef MC_ALLOC
5065 init_lcrecord_lists (); 5015 init_lcrecord_lists ();
5066 #endif /* not MC_ALLOC */ 5016 #endif /* not NEW_GC */
5067 } 5017 }
5068 5018
5069 void 5019 void
5070 syms_of_alloc (void) 5020 syms_of_alloc (void)
5071 { 5021 {