Mercurial > hg > xemacs-beta
comparison src/alloc.c @ 255:084402c475ba r20-5b26
Import from CVS: tag r20-5b26
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:21:18 +0200 |
parents | 677f6a0ee643 |
children | 405dd6d1825b |
comparison
equal
deleted
inserted
replaced
254:e92abcaa252b | 255:084402c475ba |
---|---|
33 issue nice purespace and GC stats. | 33 issue nice purespace and GC stats. |
34 Ben Wing: Cleaned up frob-block lrecord code, added error-checking | 34 Ben Wing: Cleaned up frob-block lrecord code, added error-checking |
35 and various changes for Mule, for 19.12. | 35 and various changes for Mule, for 19.12. |
36 Added bit vectors for 19.13. | 36 Added bit vectors for 19.13. |
37 Added lcrecord lists for 19.14. | 37 Added lcrecord lists for 19.14. |
38 slb: Lots of work on the purification and dump time code. | |
39 Synched Doug Lea malloc support from Emacs 20.2. | |
38 */ | 40 */ |
39 | 41 |
40 #include <config.h> | 42 #include <config.h> |
41 #include "lisp.h" | 43 #include "lisp.h" |
42 #include "sysdep.h" | 44 #include "sysdep.h" |
55 #include "redisplay.h" | 57 #include "redisplay.h" |
56 #include "specifier.h" | 58 #include "specifier.h" |
57 #include "window.h" | 59 #include "window.h" |
58 #endif | 60 #endif |
59 | 61 |
62 #ifdef DOUG_LEA_MALLOC | |
63 #include <malloc.h> | |
64 #endif | |
65 | |
60 /* #define GDB_SUCKS */ | 66 /* #define GDB_SUCKS */ |
61 | 67 |
62 /* #define VERIFY_STRING_CHARS_INTEGRITY */ | 68 #if 0 /* this is _way_ too slow to be part of the standard debug options */ |
69 #if defined(DEBUG_XEMACS) && defined(MULE) | |
70 #define VERIFY_STRING_CHARS_INTEGRITY | |
71 #endif | |
72 #endif | |
63 | 73 |
64 /* Define this to see where all that space is going... */ | 74 /* Define this to see where all that space is going... */ |
65 /* But the length of the printout is obnoxious, so limit it to testers */ | 75 /* But the length of the printout is obnoxious, so limit it to testers */ |
76 /* If somebody wants to see this they can ask for it. | |
66 #ifdef DEBUG_XEMACS | 77 #ifdef DEBUG_XEMACS |
67 #define PURESTAT | 78 #define PURESTAT |
68 #endif | 79 #endif |
80 */ | |
69 | 81 |
70 /* Define this to use malloc/free with no freelist for all datatypes, | 82 /* Define this to use malloc/free with no freelist for all datatypes, |
71 the hope being that some debugging tools may help detect | 83 the hope being that some debugging tools may help detect |
72 freed memory references */ | 84 freed memory references */ |
73 #ifdef USE_DEBUG_MALLOC /* Taking the above comment at face value -slb */ | 85 #ifdef USE_DEBUG_MALLOC /* Taking the above comment at face value -slb */ |
184 | 196 |
185 extern Lisp_Object pure[];/* moved to pure.c to speed incremental linking */ | 197 extern Lisp_Object pure[];/* moved to pure.c to speed incremental linking */ |
186 | 198 |
187 #define PUREBEG ((unsigned char *) pure) | 199 #define PUREBEG ((unsigned char *) pure) |
188 | 200 |
201 #if 0 /* This is breathing_space in XEmacs */ | |
202 /* Points to memory space allocated as "spare", | |
203 to be freed if we run out of memory. */ | |
204 static char *spare_memory; | |
205 | |
206 /* Amount of spare memory to keep in reserve. */ | |
207 #define SPARE_MEMORY (1 << 14) | |
208 #endif | |
209 | |
210 /* Number of extra blocks malloc should get when it needs more core. */ | |
211 static int malloc_hysteresis; | |
212 | |
189 /* Index in pure at which next pure object will be allocated. */ | 213 /* Index in pure at which next pure object will be allocated. */ |
190 static long pureptr; | 214 static long pureptr; |
191 | 215 |
192 #define PURIFIED(ptr) \ | 216 #define PURIFIED(ptr) \ |
193 ((uintptr_t) (ptr) < \ | 217 ((uintptr_t) (ptr) < \ |
786 #define MALLOC_OVERHEAD 20 | 810 #define MALLOC_OVERHEAD 20 |
787 #else | 811 #else |
788 #define MALLOC_OVERHEAD 8 | 812 #define MALLOC_OVERHEAD 8 |
789 #endif | 813 #endif |
790 #endif /* MALLOC_OVERHEAD */ | 814 #endif /* MALLOC_OVERHEAD */ |
815 | |
816 #if !defined(HAVE_MMAP) || defined(DOUG_LEA_MALLOC) | |
817 /* If we released our reserve (due to running out of memory), | |
818 and we have a fair amount free once again, | |
819 try to set aside another reserve in case we run out once more. | |
820 | |
821 This is called when a relocatable block is freed in ralloc.c. */ | |
822 | |
823 void | |
824 refill_memory_reserve () | |
825 { | |
826 if (breathing_space == 0) | |
827 breathing_space = (char *) malloc (4096 - MALLOC_OVERHEAD); | |
828 } | |
829 #endif | |
791 | 830 |
792 #ifdef ALLOC_NO_POOLS | 831 #ifdef ALLOC_NO_POOLS |
793 # define TYPE_ALLOC_SIZE(type, structtype) 1 | 832 # define TYPE_ALLOC_SIZE(type, structtype) 1 |
794 #else | 833 #else |
795 # define TYPE_ALLOC_SIZE(type, structtype) \ | 834 # define TYPE_ALLOC_SIZE(type, structtype) \ |
4902 #endif | 4941 #endif |
4903 XSETINT (all_bit_vectors, 0); /* Qzero may not be set yet. */ | 4942 XSETINT (all_bit_vectors, 0); /* Qzero may not be set yet. */ |
4904 XSETINT (Vgc_message, 0); | 4943 XSETINT (Vgc_message, 0); |
4905 all_lcrecords = 0; | 4944 all_lcrecords = 0; |
4906 ignore_malloc_warnings = 1; | 4945 ignore_malloc_warnings = 1; |
4946 #ifdef DOUG_LEA_MALLOC | |
4947 mallopt (M_TRIM_THRESHOLD, 128*1024); /* trim threshold */ | |
4948 mallopt (M_MMAP_THRESHOLD, 64*1024); /* mmap threshold */ | |
4949 /* mallopt (M_MMAP_MAX, 64); /* max. number of mmap'ed areas */ | |
4950 #endif | |
4907 init_string_alloc (); | 4951 init_string_alloc (); |
4908 init_string_chars_alloc (); | 4952 init_string_chars_alloc (); |
4909 init_cons_alloc (); | 4953 init_cons_alloc (); |
4910 init_symbol_alloc (); | 4954 init_symbol_alloc (); |
4911 init_compiled_function_alloc (); | 4955 init_compiled_function_alloc (); |