comparison src/alloc.c @ 3063:d30cd499e445

[xemacs-hg @ 2005-11-13 10:48:01 by ben] further error-checking, etc. alloc.c, lrecord.h: Move around the handling of setting of lheader->uid so it's in set_lheader_implementation() -- that way, even non-MC-ALLOC builds get useful uid's in their bare lrecords. Redo related code for strings so the non-ascii count that is stored in the uid isn't hosed. events.c: Save and restore the uid around event zeroing/deadbeefing. lisp.h: Set the correct value of MAX_STRING_ASCII_BEGIN under MC_ALLOC. lisp.h: rearrange the basic code handling ints and chars. basic int stuff goes first, followed by basic char stuff, followed in turn by stuff that mixes ints and chars. this is required since some basic defn's have become inline functions. XCHAR and CHARP have additional error-checking in that they check to make sure that the value in question is not just a character but a valid character (i.e. its numeric value is valid). print.c: debug_p4 now has a useful UID in all cases and uses it; but it also prints the raw header address (previously, you just got one of them). text.h: some basic char defn's that belonged in lisp.h have been moved there. valid_ichar_p() is moved too since the inline functions need it.
author ben
date Sun, 13 Nov 2005 10:48:04 +0000
parents b7f26b2f78bd
children 141c2920ea48 3742ea8250b5
comparison
equal deleted inserted replaced
3062:21d92abaac3a 3063:d30cd499e445
183 * Level 0 is most volatile, contrary to usual convention. 183 * Level 0 is most volatile, contrary to usual convention.
184 * (Of course, there's only one level at present) */ 184 * (Of course, there's only one level at present) */
185 EMACS_INT gc_generation_number[1]; 185 EMACS_INT gc_generation_number[1];
186 186
187 /* This is just for use by the printer, to allow things to print uniquely */ 187 /* This is just for use by the printer, to allow things to print uniquely */
188 static int lrecord_uid_counter; 188 int lrecord_uid_counter;
189 189
190 /* Nonzero when calling certain hooks or doing other things where 190 /* Nonzero when calling certain hooks or doing other things where
191 a GC would be bad */ 191 a GC would be bad */
192 int gc_currently_forbidden; 192 int gc_currently_forbidden;
193 193
604 implementation->static_size == size)); 604 implementation->static_size == size));
605 605
606 lheader = (struct lrecord_header *) mc_alloc (size); 606 lheader = (struct lrecord_header *) mc_alloc (size);
607 gc_checking_assert (LRECORD_FREE_P (lheader)); 607 gc_checking_assert (LRECORD_FREE_P (lheader));
608 set_lheader_implementation (lheader, implementation); 608 set_lheader_implementation (lheader, implementation);
609 lheader->uid = lrecord_uid_counter++;
610 #ifdef ALLOC_TYPE_STATS 609 #ifdef ALLOC_TYPE_STATS
611 inc_lrecord_stats (size, lheader); 610 inc_lrecord_stats (size, lheader);
612 #endif /* ALLOC_TYPE_STATS */ 611 #endif /* ALLOC_TYPE_STATS */
613 INCREMENT_CONS_COUNTER (size, implementation->name); 612 INCREMENT_CONS_COUNTER (size, implementation->name);
614 return lheader; 613 return lheader;
626 implementation->static_size == size)); 625 implementation->static_size == size));
627 626
628 lheader = (struct lrecord_header *) mc_alloc (size); 627 lheader = (struct lrecord_header *) mc_alloc (size);
629 gc_checking_assert (LRECORD_FREE_P (lheader)); 628 gc_checking_assert (LRECORD_FREE_P (lheader));
630 set_lheader_implementation (lheader, implementation); 629 set_lheader_implementation (lheader, implementation);
631 lheader->uid = lrecord_uid_counter++;
632 #ifdef ALLOC_TYPE_STATS 630 #ifdef ALLOC_TYPE_STATS
633 inc_lrecord_stats (size, lheader); 631 inc_lrecord_stats (size, lheader);
634 #endif /* ALLOC_TYPE_STATS */ 632 #endif /* ALLOC_TYPE_STATS */
635 NOSEEUM_INCREMENT_CONS_COUNTER (size, implementation->name); 633 NOSEEUM_INCREMENT_CONS_COUNTER (size, implementation->name);
636 return lheader; 634 return lheader;
2482 ALLOCATE_FIXED_TYPE (string, Lisp_String, s); 2480 ALLOCATE_FIXED_TYPE (string, Lisp_String, s);
2483 xzero (*s); 2481 xzero (*s);
2484 set_lheader_implementation (&s->u.lheader, &lrecord_string); 2482 set_lheader_implementation (&s->u.lheader, &lrecord_string);
2485 #endif /* not MC_ALLOC */ 2483 #endif /* not MC_ALLOC */
2486 2484
2485 /* The above allocations set the UID field, which overlaps with the
2486 ascii-length field, to some non-zero value. We need to zero it. */
2487 XSET_STRING_ASCII_BEGIN (wrap_string (s), 0);
2488
2487 set_lispstringp_data (s, BIG_STRING_FULLSIZE_P (fullsize) 2489 set_lispstringp_data (s, BIG_STRING_FULLSIZE_P (fullsize)
2488 ? allocate_big_string_chars (length + 1) 2490 ? allocate_big_string_chars (length + 1)
2489 : allocate_string_chars_struct (wrap_string (s), 2491 : allocate_string_chars_struct (wrap_string (s),
2490 fullsize)->chars); 2492 fullsize)->chars);
2491 2493
2710 else 2712 else
2711 { 2713 {
2712 EMACS_INT i; 2714 EMACS_INT i;
2713 Ibyte *ptr = XSTRING_DATA (val); 2715 Ibyte *ptr = XSTRING_DATA (val);
2714 2716
2715 #ifdef MC_ALLOC
2716 /* Need this for the new allocator: strings are using the uid
2717 field for ascii_begin. The uid field is set for debugging,
2718 but the string code assumes here that ascii_begin is always
2719 zero, when not touched. This assumption is not true with
2720 the new allocator, so ascii_begin has to be set to zero
2721 here. */
2722 XSET_STRING_ASCII_BEGIN (val, 0);
2723 #endif /* not MC_ALLOC */
2724
2725 for (i = XINT (length); i; i--) 2717 for (i = XINT (length); i; i--)
2726 { 2718 {
2727 Ibyte *init_ptr = init_str; 2719 Ibyte *init_ptr = init_str;
2728 switch (len) 2720 switch (len)
2729 { 2721 {
2870 /* Allocate the string header */ 2862 /* Allocate the string header */
2871 ALLOCATE_FIXED_TYPE (string, Lisp_String, s); 2863 ALLOCATE_FIXED_TYPE (string, Lisp_String, s);
2872 set_lheader_implementation (&s->u.lheader, &lrecord_string); 2864 set_lheader_implementation (&s->u.lheader, &lrecord_string);
2873 SET_C_READONLY_RECORD_HEADER (&s->u.lheader); 2865 SET_C_READONLY_RECORD_HEADER (&s->u.lheader);
2874 #endif /* not MC_ALLOC */ 2866 #endif /* not MC_ALLOC */
2867 /* Don't need to XSET_STRING_ASCII_BEGIN() here because it happens in
2868 init_string_ascii_begin(). */
2875 s->plist = Qnil; 2869 s->plist = Qnil;
2876 set_lispstringp_data (s, (Ibyte *) contents); 2870 set_lispstringp_data (s, (Ibyte *) contents);
2877 set_lispstringp_length (s, length); 2871 set_lispstringp_length (s, length);
2878 val = wrap_string (s); 2872 val = wrap_string (s);
2879 init_string_ascii_begin (val); 2873 init_string_ascii_begin (val);