Mercurial > hg > xemacs-beta
changeset 3024:b7f26b2f78bd
[xemacs-hg @ 2005-10-25 08:32:40 by ben]
more mc-alloc-related factoring; make it hard to do the wrong thing
postgresql/postgresql.c, postgresql/postgresql.h: MC-Alloc refactoring.
ldap/eldap.c, ldap/eldap.h: MC-Alloc refactoring.
alloc.c, buffer.c, console.c, emacs.c, file-coding.c, lrecord.h, lstream.c, mule-charset.c, print.c, scrollbar-gtk.c, scrollbar-msw.c, scrollbar-x.c, scrollbar.c, symbols.c, symeval.h, unicode.c, window.c, xemacs.def.in.in: rename `struct lcrecord_header' to `struct old_lcrecord_header';
likewise for `old_basic_alloc_lcrecord', `old_free_lcrecord',
`old_zero_lcrecord', `old_zero_sized_lcrecord', `old_copy_lcrecord',
`old_copy_sized_lcrecord', `old_alloc_lcrecord_type'. Created new
LISPOBJ_STORAGE_SIZE() used only on objects created through allocation
of Lisp-Object memory instead of basic xmalloc()/xfree(). This is
distinguished from malloced_storage_size(), for non-Lisp-Objects.
The definition of LISPOBJ_STORAGE_SIZE() can reduce down to
malloced_storage_size() when not MC-ALLOC, but with MC-ALLOC it's
a different function.
The whole point other than cleaning up the use of LISPOBJ_STORAGE_SIZE
is to make it harder to accidentally use the old kind (lowercase) of
function in new code, since you get a compile error.
author | ben |
---|---|
date | Tue, 25 Oct 2005 08:32:50 +0000 |
parents | d305f4207861 |
children | facf3239ba30 |
files | modules/ChangeLog modules/ldap/eldap.c modules/ldap/eldap.h modules/postgresql/postgresql.c modules/postgresql/postgresql.h src/ChangeLog src/alloc.c src/buffer.c src/console.c src/emacs.c src/file-coding.c src/lrecord.h src/lstream.c src/mule-charset.c src/print.c src/scrollbar-gtk.c src/scrollbar-msw.c src/scrollbar-x.c src/scrollbar.c src/symbols.c src/symeval.h src/unicode.c src/window.c src/xemacs.def.in.in |
diffstat | 24 files changed, 181 insertions(+), 151 deletions(-) [+] |
line wrap: on
line diff
--- a/modules/ChangeLog Tue Oct 25 07:30:42 2005 +0000 +++ b/modules/ChangeLog Tue Oct 25 08:32:50 2005 +0000 @@ -1,3 +1,17 @@ +2005-10-25 Ben Wing <ben@xemacs.org> + + * postgresql/postgresql.c (allocate_pgconn): + * postgresql/postgresql.c (allocate_pgresult): + * postgresql/postgresql.h (struct Lisp_PGconn): + * postgresql/postgresql.h (struct Lisp_PGresult): + MC-Alloc refactoring. + +2005-10-25 Ben Wing <ben@xemacs.org> + + * ldap/eldap.c (allocate_ldap): + * ldap/eldap.h (struct Lisp_LDAP): + MC-Alloc refactoring. + 2005-10-21 Stephen J. Turnbull <stephen@xemacs.org> UNDO:
--- a/modules/ldap/eldap.c Tue Oct 25 07:30:42 2005 +0000 +++ b/modules/ldap/eldap.c Tue Oct 25 08:32:50 2005 +0000 @@ -141,11 +141,7 @@ static Lisp_LDAP * allocate_ldap (void) { -#ifdef MC_ALLOC - Lisp_LDAP *ldap = alloc_lrecord_type (Lisp_LDAP, &lrecord_ldap); -#else /* not MC_ALLOC */ - Lisp_LDAP *ldap = alloc_lcrecord_type (Lisp_LDAP, &lrecord_ldap); -#endif /* not MC_ALLOC */ + Lisp_LDAP *ldap = ALLOC_LCRECORD_TYPE (Lisp_LDAP, &lrecord_ldap); ldap->ld = NULL; ldap->host = Qnil;
--- a/modules/ldap/eldap.h Tue Oct 25 07:30:42 2005 +0000 +++ b/modules/ldap/eldap.h Tue Oct 25 08:32:50 2005 +0000 @@ -31,13 +31,7 @@ struct Lisp_LDAP { -#ifdef MC_ALLOC - /* lrecord header */ - struct lrecord_header header; -#else /* not MC_ALLOC */ - /* lcrecord header */ - struct lcrecord_header header; -#endif /* not MC_ALLOC */ + struct LCRECORD_HEADER header; /* The LDAP connection handle used by the LDAP API */ LDAP *ld; /* Name of the host we connected to */
--- a/modules/postgresql/postgresql.c Tue Oct 25 07:30:42 2005 +0000 +++ b/modules/postgresql/postgresql.c Tue Oct 25 08:32:50 2005 +0000 @@ -238,21 +238,11 @@ allocate_pgconn (void) { #ifdef RUNNING_XEMACS_21_1 -#ifdef MC_ALLOC - Lisp_PGconn *pgconn = alloc_lrecord_type (Lisp_PGconn, - lrecord_pgconn); -#else /* not MC_ALLOC */ - Lisp_PGconn *pgconn = alloc_lcrecord_type (Lisp_PGconn, + Lisp_PGconn *pgconn = ALLOC_LCRECORD_TYPE (Lisp_PGconn, lrecord_pgconn); -#endif /* not MC_ALLOC */ #else -#ifdef MC_ALLOC - Lisp_PGconn *pgconn = alloc_lrecord_type (Lisp_PGconn, - &lrecord_pgconn); -#else /* not MC_ALLOC */ - Lisp_PGconn *pgconn = alloc_lcrecord_type (Lisp_PGconn, + Lisp_PGconn *pgconn = ALLOC_LCRECORD_TYPE (Lisp_PGconn, &lrecord_pgconn); -#endif /* not MC_ALLOC */ #endif pgconn->pgconn = (PGconn *)NULL; return pgconn; @@ -373,21 +363,11 @@ allocate_pgresult (void) { #ifdef RUNNING_XEMACS_21_1 -#ifdef MC_ALLOC - Lisp_PGresult *pgresult = alloc_lrecord_type (Lisp_PGresult, - lrecord_pgresult); -#else /* not MC_ALLOC */ - Lisp_PGresult *pgresult = alloc_lcrecord_type (Lisp_PGresult, + Lisp_PGresult *pgresult = ALLOC_LCRECORD_TYPE (Lisp_PGresult, lrecord_pgresult); -#endif /* not MC_ALLOC */ #else -#ifdef MC_ALLOC - Lisp_PGresult *pgresult = alloc_lrecord_type (Lisp_PGresult, - &lrecord_pgresult); -#else /* not MC_ALLOC */ - Lisp_PGresult *pgresult = alloc_lcrecord_type (Lisp_PGresult, + Lisp_PGresult *pgresult = ALLOC_LCRECORD_TYPE (Lisp_PGresult, &lrecord_pgresult); -#endif /* not MC_ALLOC */ #endif pgresult->pgresult = (PGresult *)NULL; return pgresult;
--- a/modules/postgresql/postgresql.h Tue Oct 25 07:30:42 2005 +0000 +++ b/modules/postgresql/postgresql.h Tue Oct 25 08:32:50 2005 +0000 @@ -28,11 +28,7 @@ */ struct Lisp_PGconn { -#ifdef MC_ALLOC - struct lrecord_header header; -#else /* not MC_ALLOC */ - struct lcrecord_header header; -#endif /* not MC_ALLOC */ + struct LCRECORD_HEADER header; PGconn *pgconn; }; typedef struct Lisp_PGconn Lisp_PGconn; @@ -52,11 +48,7 @@ */ struct Lisp_PGresult { -#ifdef MC_ALLOC - struct lrecord_header header; -#else /* not MC_ALLOC */ - struct lcrecord_header header; -#endif /* not MC_ALLOC */ + struct LCRECORD_HEADER header; PGresult *pgresult; }; typedef struct Lisp_PGresult Lisp_PGresult;
--- a/src/ChangeLog Tue Oct 25 07:30:42 2005 +0000 +++ b/src/ChangeLog Tue Oct 25 08:32:50 2005 +0000 @@ -1,3 +1,59 @@ +2005-10-25 Ben Wing <ben@xemacs.org> + + * alloc.c: + * alloc.c (old_basic_alloc_lcrecord): + * alloc.c (very_old_free_lcrecord): + * alloc.c (disksave_object_finalization_1): + * alloc.c (copy_lisp_object): + * alloc.c (make_lcrecord_list): + * alloc.c (alloc_managed_lcrecord): + * alloc.c (old_free_lcrecord): + * alloc.c (GC_CHECK_NOT_FREE): + * alloc.c (tick_lcrecord_stats): + * alloc.c (sweep_lcrecords_1): + * buffer.c (compute_buffer_usage): + * buffer.c (DEFVAR_BUFFER_LOCAL_1): + * console.c (DEFVAR_CONSOLE_LOCAL_1): + * emacs.c: + * emacs.c (main_1): + * file-coding.c (allocate_coding_system): + * lrecord.h: + * lrecord.h (struct old_lcrecord_header): + * lrecord.h (struct free_lcrecord_header): + * lrecord.h (struct lrecord_implementation): + * lrecord.h (struct lcrecord_list): + * lrecord.h (old_alloc_lcrecord_type): + * lrecord.h (old_copy_sized_lcrecord): + * lrecord.h (old_zero_lcrecord): + * lstream.c (Lstream_new): + * mule-charset.c (compute_charset_usage): + * print.c (debug_p4): + * scrollbar-gtk.c (gtk_compute_scrollbar_instance_usage): + * scrollbar-msw.c (mswindows_compute_scrollbar_instance_usage): + * scrollbar-x.c (x_compute_scrollbar_instance_usage): + * scrollbar.c (compute_scrollbar_instance_usage): + * symbols.c (guts_of_unbound_marker): + * symeval.h (DEFVAR_SYMVAL_FWD): + * unicode.c (compute_from_unicode_table_size_1): + * unicode.c (compute_to_unicode_table_size_1): + * window.c (compute_window_mirror_usage): + * window.c (compute_window_usage): + * xemacs.def.in.in: + rename `struct lcrecord_header' to `struct old_lcrecord_header'; + likewise for `old_basic_alloc_lcrecord', `old_free_lcrecord', + `old_zero_lcrecord', `old_zero_sized_lcrecord', `old_copy_lcrecord', + `old_copy_sized_lcrecord', `old_alloc_lcrecord_type'. Created new + LISPOBJ_STORAGE_SIZE() used only on objects created through allocation + of Lisp-Object memory instead of basic xmalloc()/xfree(). This is + distinguished from malloced_storage_size(), for non-Lisp-Objects. + The definition of LISPOBJ_STORAGE_SIZE() can reduce down to + malloced_storage_size() when not MC-ALLOC, but with MC-ALLOC it's + a different function. + + The whole point other than cleaning up the use of LISPOBJ_STORAGE_SIZE + is to make it harder to accidentally use the old kind (lowercase) of + function in new code, since you get a compile error. + 2005-10-25 Ben Wing <ben@xemacs.org> * frame-msw.c (mswindows_window_id):
--- a/src/alloc.c Tue Oct 25 07:30:42 2005 +0000 +++ b/src/alloc.c Tue Oct 25 08:32:50 2005 +0000 @@ -587,7 +587,7 @@ /* lcrecords are chained together through their "next" field. After doing the mark phase, GC will walk this linked list and free any lcrecord which hasn't been marked. */ -static struct lcrecord_header *all_lcrecords; +static struct old_lcrecord_header *all_lcrecords; #endif /* not MC_ALLOC */ #ifdef MC_ALLOC @@ -653,10 +653,10 @@ specified size. See lrecord.h. */ void * -basic_alloc_lcrecord (Bytecount size, - const struct lrecord_implementation *implementation) -{ - struct lcrecord_header *lcheader; +old_basic_alloc_lcrecord (Bytecount size, + const struct lrecord_implementation *implementation) +{ + struct old_lcrecord_header *lcheader; type_checking_assert ((implementation->static_size == 0 ? @@ -667,7 +667,7 @@ && (! (implementation->hash == NULL && implementation->equal != NULL))); - lcheader = (struct lcrecord_header *) allocate_lisp_storage (size); + lcheader = (struct old_lcrecord_header *) allocate_lisp_storage (size); set_lheader_implementation (&lcheader->lheader, implementation); lcheader->next = all_lcrecords; #if 1 /* mly prefers to see small ID numbers */ @@ -689,7 +689,7 @@ * Otherwise, just let the GC do its job -- that's what it's there for */ void -very_old_free_lcrecord (struct lcrecord_header *lcrecord) +very_old_free_lcrecord (struct old_lcrecord_header *lcrecord) { if (all_lcrecords == lcrecord) { @@ -697,10 +697,10 @@ } else { - struct lrecord_header *header = all_lcrecords; + struct old_lcrecord_header *header = all_lcrecords; for (;;) { - struct lrecord_header *next = header->next; + struct old_lcrecord_header *next = header->next; if (next == lcrecord) { header->next = lrecord->next; @@ -727,7 +727,7 @@ #ifdef MC_ALLOC mc_finalize_for_disksave (); #else /* not MC_ALLOC */ - struct lcrecord_header *header; + struct old_lcrecord_header *header; for (header = all_lcrecords; header; header = header->next) { @@ -760,9 +760,11 @@ (char *) XRECORD_LHEADER (src) + sizeof (struct lrecord_header), size - sizeof (struct lrecord_header)); else - memcpy ((char *) XRECORD_LHEADER (dst) + sizeof (struct lcrecord_header), - (char *) XRECORD_LHEADER (src) + sizeof (struct lcrecord_header), - size - sizeof (struct lcrecord_header)); + memcpy ((char *) XRECORD_LHEADER (dst) + + sizeof (struct old_lcrecord_header), + (char *) XRECORD_LHEADER (src) + + sizeof (struct old_lcrecord_header), + size - sizeof (struct old_lcrecord_header)); #endif /* not MC_ALLOC */ } @@ -2887,7 +2889,7 @@ /************************************************************************/ /* Lcrecord lists are used to manage the allocation of particular - sorts of lcrecords, to avoid calling basic_alloc_lcrecord() (and thus + sorts of lcrecords, to avoid calling BASIC_ALLOC_LCRECORD() (and thus malloc() and garbage-collection junk) as much as possible. It is similar to the Blocktype class. @@ -2959,11 +2961,11 @@ make_lcrecord_list (Elemcount size, const struct lrecord_implementation *implementation) { - /* Don't use alloc_lcrecord_type() avoid infinite recursion + /* Don't use old_alloc_lcrecord_type() avoid infinite recursion allocating this, */ struct lcrecord_list *p = (struct lcrecord_list *) - basic_alloc_lcrecord (sizeof (struct lcrecord_list), - &lrecord_lcrecord_list); + old_basic_alloc_lcrecord (sizeof (struct lcrecord_list), + &lrecord_lcrecord_list); p->implementation = implementation; p->size = size; @@ -3005,12 +3007,12 @@ free_header->lcheader.free = 0; /* Put back the correct type, as we set it to lrecord_type_free. */ lheader->type = list->implementation->lrecord_type_index; - zero_sized_lcrecord (free_header, list->size); + old_zero_sized_lcrecord (free_header, list->size); return val; } else - return wrap_pointer_1 (basic_alloc_lcrecord (list->size, - list->implementation)); + return wrap_pointer_1 (old_basic_alloc_lcrecord (list->size, + list->implementation)); } /* "Free" a Lisp object LCRECORD by placing it on its associated free list @@ -3081,7 +3083,7 @@ } void -free_lcrecord (Lisp_Object rec) +old_free_lcrecord (Lisp_Object rec) { int type = XRECORD_LHEADER (rec)->type; @@ -3617,7 +3619,7 @@ #define GC_CHECK_NOT_FREE(lheader) \ gc_checking_assert (! LRECORD_FREE_P (lheader)); \ gc_checking_assert (LHEADER_IMPLEMENTATION (lheader)->basic_p || \ - ! ((struct lcrecord_header *) lheader)->free) + ! ((struct old_lcrecord_header *) lheader)->free) #endif /* MC_ALLOC */ #ifdef USE_KKCC @@ -4148,7 +4150,7 @@ { int type_index = h->type; - if (((struct lcrecord_header *) h)->free) + if (((struct old_lcrecord_header *) h)->free) { gc_checking_assert (!free_p); lcrecord_stats[type_index].instances_on_free_list++; @@ -4175,9 +4177,9 @@ #ifndef MC_ALLOC /* Free all unmarked records */ static void -sweep_lcrecords_1 (struct lcrecord_header **prev, int *used) -{ - struct lcrecord_header *header; +sweep_lcrecords_1 (struct old_lcrecord_header **prev, int *used) +{ + struct old_lcrecord_header *header; int num_used = 0; /* int total_size = 0; */ @@ -4222,11 +4224,11 @@ } else { - struct lcrecord_header *next = header->next; + struct old_lcrecord_header *next = header->next; *prev = next; tick_lcrecord_stats (h, 1); /* used to call finalizer right here. */ - xfree (header, struct lcrecord_header *); + xfree (header, struct old_lcrecord_header *); header = next; } }
--- a/src/buffer.c Tue Oct 25 07:30:42 2005 +0000 +++ b/src/buffer.c Tue Oct 25 08:32:50 2005 +0000 @@ -1757,7 +1757,7 @@ struct overhead_stats *ovstats) { xzero (*stats); - stats->other += MALLOCED_STORAGE_SIZE (b, sizeof (*b), ovstats); + stats->other += LISPOBJ_STORAGE_SIZE (b, sizeof (*b), ovstats); stats->text += compute_buffer_text_usage (b, ovstats); stats->markers += compute_buffer_marker_usage (b, ovstats); stats->extents += compute_buffer_extent_usage (b, ovstats); @@ -2146,7 +2146,7 @@ static const struct symbol_value_forward I_hate_C = \ { /* struct symbol_value_forward */ \ { /* struct symbol_value_magic */ \ - { /* struct lcrecord_header */ \ + { /* struct old_lcrecord_header */ \ { /* struct lrecord_header */ \ lrecord_type_symbol_value_forward, /* lrecord_type_index */ \ 1, /* mark bit */ \
--- a/src/console.c Tue Oct 25 07:30:42 2005 +0000 +++ b/src/console.c Tue Oct 25 08:32:50 2005 +0000 @@ -1341,7 +1341,7 @@ static const struct symbol_value_forward I_hate_C = \ { /* struct symbol_value_forward */ \ { /* struct symbol_value_magic */ \ - { /* struct lcrecord_header */ \ + { /* struct old_lcrecord_header */ \ { /* struct lrecord_header */ \ lrecord_type_symbol_value_forward, /* lrecord_type_index */ \ 1, /* mark bit */ \
--- a/src/emacs.c Tue Oct 25 07:30:42 2005 +0000 +++ b/src/emacs.c Tue Oct 25 08:32:50 2005 +0000 @@ -2,7 +2,7 @@ Copyright (C) 1985, 1986, 1987, 1992, 1993, 1994 Free Software Foundation, Inc. Copyright (C) 1995 Sun Microsystems, Inc. - Copyright (C) 2000, 2001, 2002, 2003, 2004 Ben Wing. + Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Ben Wing. This file is part of XEmacs. @@ -1973,7 +1973,8 @@ - make_int() - make_char() - make_extent() - - basic_alloc_lcrecord() + - BASIC_ALLOC_LCRECORD() + - ALLOC_LCRECORD_TYPE() - Fcons() - listN() - make_lcrecord_list()
--- a/src/file-coding.c Tue Oct 25 07:30:42 2005 +0000 +++ b/src/file-coding.c Tue Oct 25 08:32:50 2005 +0000 @@ -698,13 +698,8 @@ { Bytecount total_size = offsetof (Lisp_Coding_System, data) + data_size; Lisp_Coding_System *codesys = -#ifdef MC_ALLOC - (Lisp_Coding_System *) alloc_lrecord (total_size, - &lrecord_coding_system); -#else /* not MC_ALLOC */ - (Lisp_Coding_System *) basic_alloc_lcrecord (total_size, + (Lisp_Coding_System *) BASIC_ALLOC_LCRECORD (total_size, &lrecord_coding_system); -#endif /* not MC_ALLOC */ codesys->methods = codesys_meths; #define MARKED_SLOT(x) codesys->x = Qnil;
--- a/src/lrecord.h Tue Oct 25 07:30:42 2005 +0000 +++ b/src/lrecord.h Tue Oct 25 08:32:50 2005 +0000 @@ -67,9 +67,9 @@ Lcrecords are used for less common sorts of objects that don't do their own allocation. Each such object is malloc()ed individually, and the objects are chained together through a `next' pointer. - Lcrecords have a `struct lcrecord_header' at the top, which + Lcrecords have a `struct old_lcrecord_header' at the top, which contains a `struct lrecord_header' and a `next' pointer, and are - allocated using alloc_lcrecord_type() or its variants. + allocated using old_alloc_lcrecord_type() or its variants. Creating a new lcrecord type is fairly easy; just follow the lead of some existing type (e.g. hash tables). Note that you @@ -81,6 +81,27 @@ */ #endif /* not MC_ALLOC */ +#ifdef MC_ALLOC +#define ALLOC_LCRECORD_TYPE alloc_lrecord_type +#define COPY_SIZED_LCRECORD copy_sized_lrecord +#define COPY_LCRECORD copy_lrecord +#define LISPOBJ_STORAGE_SIZE(ptr, size, stats) \ + mc_alloced_storage_size (size, stats) +#define ZERO_LCRECORD zero_lrecord +#define LCRECORD_HEADER lrecord_header +#define BASIC_ALLOC_LCRECORD alloc_lrecord +#define FREE_LCRECORD free_lrecord +#else +#define ALLOC_LCRECORD_TYPE old_alloc_lcrecord_type +#define COPY_SIZED_LCRECORD old_copy_sized_lcrecord +#define COPY_LCRECORD old_copy_lcrecord +#define LISPOBJ_STORAGE_SIZE malloced_storage_size +#define ZERO_LCRECORD old_zero_lcrecord +#define LCRECORD_HEADER old_lcrecord_header +#define BASIC_ALLOC_LCRECORD old_basic_alloc_lcrecord +#define FREE_LCRECORD old_free_lcrecord +#endif + BEGIN_C_DECLS struct lrecord_header @@ -145,13 +166,13 @@ #endif /* not MC_ALLOC */ #ifndef MC_ALLOC -struct lcrecord_header +struct old_lcrecord_header { struct lrecord_header lheader; /* The `next' field is normally used to chain all lcrecords together so that the GC can find (and free) all of them. - `basic_alloc_lcrecord' threads lcrecords together. + `old_basic_alloc_lcrecord' threads lcrecords together. The `next' field may be used for other purposes as long as some other mechanism is provided for letting the GC do its work. @@ -159,7 +180,7 @@ For example, the event and marker object types allocate members out of memory chunks, and are able to find all unmarked members by sweeping through the elements of the list of chunks. */ - struct lcrecord_header *next; + struct old_lcrecord_header *next; /* The `uid' field is just for debugging/printing convenience. Having this slot doesn't hurt us much spacewise, since an @@ -179,7 +200,7 @@ /* Used for lcrecords in an lcrecord-list. */ struct free_lcrecord_header { - struct lcrecord_header lcheader; + struct old_lcrecord_header lcheader; Lisp_Object chain; }; #endif /* not MC_ALLOC */ @@ -344,7 +365,8 @@ /* Only one of `static_size' and `size_in_bytes_method' is non-0. */ #else /* not MC_ALLOC */ /* Only one of `static_size' and `size_in_bytes_method' is non-0. - If both are 0, this type is not instantiable by basic_alloc_lcrecord(). */ + If both are 0, this type is not instantiable by + old_basic_alloc_lcrecord(). */ #endif /* not MC_ALLOC */ Bytecount static_size; Bytecount (*size_in_bytes_method) (const void *header); @@ -354,7 +376,7 @@ #ifndef MC_ALLOC /* A "basic" lrecord is any lrecord that's not an lcrecord, i.e. - one that does not have an lcrecord_header at the front and which + one that does not have an old_lcrecord_header at the front and which is (usually) allocated in frob blocks. */ unsigned int basic_p :1; #endif /* not MC_ALLOC */ @@ -1496,7 +1518,7 @@ struct lcrecord_list { - struct lcrecord_header header; + struct LCRECORD_HEADER header; Lisp_Object free; Elemcount size; const struct lrecord_implementation *implementation; @@ -1517,7 +1539,7 @@ lrecords. lcrecords themselves are divided into three types: (1) auto-managed, (2) hand-managed, and (3) unmanaged. "Managed" refers to using a special object called an lcrecord-list to keep track of freed - lcrecords, which can freed with free_lcrecord() or the like and later be + lcrecords, which can freed with FREE_LCRECORD() or the like and later be recycled when a new lcrecord is required, rather than requiring new malloc(). Thus, allocation of lcrecords can be very cheap. (Technically, the lcrecord-list manager could divide up large @@ -1531,9 +1553,9 @@ in particular dictate the various types of management: -- "Auto-managed" means that you just go ahead and allocate the lcrecord - whenever you want, using alloc_lcrecord_type(), and the appropriate + whenever you want, using old_alloc_lcrecord_type(), and the appropriate lcrecord-list manager is automatically created. To free, you just call - "free_lcrecord()" and the appropriate lcrecord-list manager is + "FREE_LCRECORD()" and the appropriate lcrecord-list manager is automatically located and called. The limitation here of course is that all your objects are of the same size. (#### Eventually we should have a more sophisticated system that tracks the sizes seen and creates one @@ -1554,7 +1576,7 @@ to hand-manage them, or (b) the objects you create are always or almost always Lisp-visible, and thus there's no point in freeing them (and it wouldn't be safe to do so). You just create them with - basic_alloc_lcrecord(), and that's it. + BASIC_ALLOC_LCRECORD(), and that's it. --ben @@ -1567,9 +1589,9 @@ 1) Create an lcrecord-list object using make_lcrecord_list(). This is often done at initialization. Remember to staticpro_nodump() this object! The arguments to make_lcrecord_list() are the same as would be - passed to basic_alloc_lcrecord(). + passed to BASIC_ALLOC_LCRECORD(). - 2) Instead of calling basic_alloc_lcrecord(), call alloc_managed_lcrecord() + 2) Instead of calling BASIC_ALLOC_LCRECORD(), call alloc_managed_lcrecord() and pass the lcrecord-list earlier created. 3) When done with the lcrecord, call free_managed_lcrecord(). The @@ -1580,7 +1602,7 @@ lcrecord goodbye as if it were garbage-collected. This means: -- the contents of the freed lcrecord are undefined, and the contents of something produced by alloc_managed_lcrecord() - are undefined, just like for basic_alloc_lcrecord(). + are undefined, just like for BASIC_ALLOC_LCRECORD(). -- the mark method for the lcrecord's type will *NEVER* be called on freed lcrecords. -- the finalize method for the lcrecord's type will be called @@ -1588,8 +1610,8 @@ */ /* UNMANAGED MODEL: */ -void *basic_alloc_lcrecord (Bytecount size, - const struct lrecord_implementation *); +void *old_basic_alloc_lcrecord (Bytecount size, + const struct lrecord_implementation *); /* HAND-MANAGED MODEL: */ Lisp_Object make_lcrecord_list (Elemcount size, @@ -1603,27 +1625,28 @@ alloc_automanaged_lcrecord (Bytecount size, const struct lrecord_implementation *); -#define alloc_lcrecord_type(type, lrecord_implementation) \ +#define old_alloc_lcrecord_type(type, lrecord_implementation) \ ((type *) alloc_automanaged_lcrecord (sizeof (type), lrecord_implementation)) -void free_lcrecord (Lisp_Object rec); +void old_free_lcrecord (Lisp_Object rec); /* Copy the data from one lcrecord structure into another, but don't overwrite the header information. */ -#define copy_sized_lcrecord(dst, src, size) \ - memcpy ((Rawbyte *) (dst) + sizeof (struct lcrecord_header), \ - (Rawbyte *) (src) + sizeof (struct lcrecord_header), \ - (size) - sizeof (struct lcrecord_header)) +#define old_copy_sized_lcrecord(dst, src, size) \ + memcpy ((Rawbyte *) (dst) + sizeof (struct old_lcrecord_header), \ + (Rawbyte *) (src) + sizeof (struct old_lcrecord_header), \ + (size) - sizeof (struct old_lcrecord_header)) -#define copy_lcrecord(dst, src) copy_sized_lcrecord (dst, src, sizeof (*(dst))) +#define old_copy_lcrecord(dst, src) \ + old_copy_sized_lcrecord (dst, src, sizeof (*(dst))) -#define zero_sized_lcrecord(lcr, size) \ - memset ((Rawbyte *) (lcr) + sizeof (struct lcrecord_header), 0, \ - (size) - sizeof (struct lcrecord_header)) +#define old_zero_sized_lcrecord(lcr, size) \ + memset ((Rawbyte *) (lcr) + sizeof (struct old_lcrecord_header), 0, \ + (size) - sizeof (struct old_lcrecord_header)) -#define zero_lcrecord(lcr) zero_sized_lcrecord (lcr, sizeof (*(lcr))) +#define old_zero_lcrecord(lcr) old_zero_sized_lcrecord (lcr, sizeof (*(lcr))) #else /* MC_ALLOC */ @@ -1694,27 +1717,6 @@ return detagged_lisp_object_size (XRECORD_LHEADER (o)); } -#ifdef MC_ALLOC -#define ALLOC_LCRECORD_TYPE alloc_lrecord_type -#define COPY_SIZED_LCRECORD copy_sized_lrecord -#define COPY_LCRECORD copy_lrecord -#define MALLOCED_STORAGE_SIZE(ptr, size, stats) \ - mc_alloced_storage_size (size, stats) -#define ZERO_LCRECORD zero_lrecord -#define LCRECORD_HEADER lrecord_header -#define BASIC_ALLOC_LCRECORD alloc_lrecord -#define FREE_LCRECORD free_lrecord -#else -#define ALLOC_LCRECORD_TYPE alloc_lcrecord_type -#define COPY_SIZED_LCRECORD copy_sized_lcrecord -#define COPY_LCRECORD copy_lcrecord -#define MALLOCED_STORAGE_SIZE malloced_storage_size -#define ZERO_LCRECORD zero_lcrecord -#define LCRECORD_HEADER lcrecord_header -#define BASIC_ALLOC_LCRECORD basic_alloc_lcrecord -#define FREE_LCRECORD free_lcrecord -#endif - /************************************************************************/ /* Dumping */
--- a/src/lstream.c Tue Oct 25 07:30:42 2005 +0000 +++ b/src/lstream.c Tue Oct 25 08:32:50 2005 +0000 @@ -220,7 +220,6 @@ } p = XLSTREAM (alloc_managed_lcrecord (Vlstream_free_list[i])); -#define COPY_SIZED_LCRECORD copy_sized_lcrecord #endif /* not MC_ALLOC */ /* Zero it out, except the header. */ memset ((char *) p + sizeof (p->header), '\0',
--- a/src/mule-charset.c Tue Oct 25 07:30:42 2005 +0000 +++ b/src/mule-charset.c Tue Oct 25 08:32:50 2005 +0000 @@ -880,7 +880,7 @@ { struct Lisp_Charset *c = XCHARSET (charset); xzero (*stats); - stats->other += MALLOCED_STORAGE_SIZE (c, sizeof (*c), ovstats); + stats->other += LISPOBJ_STORAGE_SIZE (c, sizeof (*c), ovstats); stats->from_unicode += compute_from_unicode_table_size (charset, ovstats); stats->to_unicode += compute_to_unicode_table_size (charset, ovstats); }
--- a/src/print.c Tue Oct 25 07:30:42 2005 +0000 +++ b/src/print.c Tue Oct 25 08:32:50 2005 +0000 @@ -2219,7 +2219,7 @@ LHEADER_IMPLEMENTATION (header)->name, LHEADER_IMPLEMENTATION (header)->basic_p ? (EMACS_INT) header : - ((struct lcrecord_header *) header)->uid); + ((struct old_lcrecord_header *) header)->uid); #endif /* not MC_ALLOC */ }
--- a/src/scrollbar-gtk.c Tue Oct 25 07:30:42 2005 +0000 +++ b/src/scrollbar-gtk.c Tue Oct 25 08:32:50 2005 +0000 @@ -484,7 +484,7 @@ struct gtk_scrollbar_data *data = (struct gtk_scrollbar_data *) inst->scrollbar_data; - total += MALLOCED_STORAGE_SIZE (data, sizeof (*data), ovstats); + total += malloced_storage_size (data, sizeof (*data), ovstats); inst = inst->next; }
--- a/src/scrollbar-msw.c Tue Oct 25 07:30:42 2005 +0000 +++ b/src/scrollbar-msw.c Tue Oct 25 08:32:50 2005 +0000 @@ -433,7 +433,7 @@ struct mswindows_scrollbar_data *data = (struct mswindows_scrollbar_data *) inst->scrollbar_data; - total += MALLOCED_STORAGE_SIZE (data, sizeof (*data), ovstats); + total += malloced_storage_size (data, sizeof (*data), ovstats); inst = inst->next; }
--- a/src/scrollbar-x.c Tue Oct 25 07:30:42 2005 +0000 +++ b/src/scrollbar-x.c Tue Oct 25 08:32:50 2005 +0000 @@ -703,8 +703,8 @@ struct x_scrollbar_data *data = (struct x_scrollbar_data *) inst->scrollbar_data; - total += MALLOCED_STORAGE_SIZE (data, sizeof (*data), ovstats); - total += MALLOCED_STORAGE_SIZE (data->name, 1 + strlen (data->name), + total += malloced_storage_size (data, sizeof (*data), ovstats); + total += malloced_storage_size (data->name, 1 + strlen (data->name), ovstats); inst = inst->next; }
--- a/src/scrollbar.c Tue Oct 25 07:30:42 2005 +0000 +++ b/src/scrollbar.c Tue Oct 25 08:32:50 2005 +0000 @@ -272,7 +272,7 @@ while (inst) { - total += MALLOCED_STORAGE_SIZE (inst, sizeof (*inst), ovstats); + total += LISPOBJ_STORAGE_SIZE (inst, sizeof (*inst), ovstats); inst = inst->next; }
--- a/src/symbols.c Tue Oct 25 07:30:42 2005 +0000 +++ b/src/symbols.c Tue Oct 25 08:32:50 2005 +0000 @@ -3256,7 +3256,7 @@ /* some losing systems can't have static vars at function scope... */ static const struct symbol_value_magic guts_of_unbound_marker = { /* struct symbol_value_magic */ - { /* struct lcrecord_header */ + { /* struct old_lcrecord_header */ { /* struct lrecord_header */ lrecord_type_symbol_value_forward, /* lrecord_type_index */ 1, /* mark bit */
--- a/src/symeval.h Tue Oct 25 07:30:42 2005 +0000 +++ b/src/symeval.h Tue Oct 25 08:32:50 2005 +0000 @@ -420,7 +420,7 @@ static const struct symbol_value_forward I_hate_C = \ { /* struct symbol_value_forward */ \ { /* struct symbol_value_magic */ \ - { /* struct lcrecord_header */ \ + { /* struct old_lcrecord_header */ \ { /* struct lrecord_header */ \ lrecord_type_symbol_value_forward, /* lrecord_type_index */ \ 1, /* mark bit */ \
--- a/src/unicode.c Tue Oct 25 07:30:42 2005 +0000 +++ b/src/unicode.c Tue Oct 25 08:32:50 2005 +0000 @@ -548,7 +548,7 @@ } } - size += MALLOCED_STORAGE_SIZE (table, + size += malloced_storage_size (table, 256 * (level == 1 ? sizeof (short) : sizeof (void *)), stats); @@ -573,7 +573,7 @@ } } - size += MALLOCED_STORAGE_SIZE (table, + size += malloced_storage_size (table, 96 * (level == 1 ? sizeof (int) : sizeof (void *)), stats);
--- a/src/window.c Tue Oct 25 07:30:42 2005 +0000 +++ b/src/window.c Tue Oct 25 08:32:50 2005 +0000 @@ -5096,8 +5096,7 @@ { if (!mir) return; - stats->other += MALLOCED_STORAGE_SIZE (mir, sizeof (struct window_mirror), - ovstats); + stats->other += LISPOBJ_STORAGE_SIZE (mir, sizeof (*mir), ovstats); #ifdef HAVE_SCROLLBARS { struct device *d = XDEVICE (FRAME_DEVICE (mir->frame)); @@ -5121,7 +5120,7 @@ struct overhead_stats *ovstats) { xzero (*stats); - stats->other += MALLOCED_STORAGE_SIZE (w, sizeof (struct window), ovstats); + stats->other += LISPOBJ_STORAGE_SIZE (w, sizeof (*w), ovstats); stats->face += compute_face_cachel_usage (w->face_cachels, ovstats); stats->glyph += compute_glyph_cachel_usage (w->glyph_cachels, ovstats); stats->line_start +=
--- a/src/xemacs.def.in.in Tue Oct 25 07:30:42 2005 +0000 +++ b/src/xemacs.def.in.in Tue Oct 25 08:32:50 2005 +0000 @@ -18,7 +18,7 @@ #endif mc_alloc /* DEFSUBR */ #else /* not MC_ALLOC */ -alloc_automanaged_lcrecord /* alloc_lcrecord_type */ +alloc_automanaged_lcrecord /* old_alloc_lcrecord_type */ #endif /* not MC_ALLOC */ apply1 #ifdef USE_ASSERTIONS