comparison src/alloc.c @ 72027:107f9a044a0a

(pure_bytes_used_lisp, pure_bytes_used_non_lisp): New vars. (init_alloc_once): Initialize them. (pure_alloc): Allocate non-Lisp objects from the end of pure storage without alignment.
author YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
date Thu, 20 Jul 2006 01:01:04 +0000
parents 3254b987edcb
children fe7f8d2385f8
comparison
equal deleted inserted replaced
72026:895bcb409f45 72027:107f9a044a0a
287 (((PNTR_COMPARISON_TYPE) (P) \ 287 (((PNTR_COMPARISON_TYPE) (P) \
288 < (PNTR_COMPARISON_TYPE) ((char *) purebeg + pure_size)) \ 288 < (PNTR_COMPARISON_TYPE) ((char *) purebeg + pure_size)) \
289 && ((PNTR_COMPARISON_TYPE) (P) \ 289 && ((PNTR_COMPARISON_TYPE) (P) \
290 >= (PNTR_COMPARISON_TYPE) purebeg)) 290 >= (PNTR_COMPARISON_TYPE) purebeg))
291 291
292 /* Index in pure at which next pure object will be allocated.. */ 292 /* Total number of bytes allocated in pure storage. */
293 293
294 EMACS_INT pure_bytes_used; 294 EMACS_INT pure_bytes_used;
295
296 /* Index in pure at which next pure Lisp object will be allocated.. */
297
298 static EMACS_INT pure_bytes_used_lisp;
299
300 /* Number of bytes allocated for non-Lisp objects in pure storage. */
301
302 static EMACS_INT pure_bytes_used_non_lisp;
295 303
296 /* If nonzero, this is a warning delivered by malloc and not yet 304 /* If nonzero, this is a warning delivered by malloc and not yet
297 displayed. */ 305 displayed. */
298 306
299 char *pending_malloc_warning; 307 char *pending_malloc_warning;
4690 Pure Storage Management 4698 Pure Storage Management
4691 ***********************************************************************/ 4699 ***********************************************************************/
4692 4700
4693 /* Allocate room for SIZE bytes from pure Lisp storage and return a 4701 /* Allocate room for SIZE bytes from pure Lisp storage and return a
4694 pointer to it. TYPE is the Lisp type for which the memory is 4702 pointer to it. TYPE is the Lisp type for which the memory is
4695 allocated. TYPE < 0 means it's not used for a Lisp object. 4703 allocated. TYPE < 0 means it's not used for a Lisp object. */
4696
4697 If store_pure_type_info is set and TYPE is >= 0, the type of
4698 the allocated object is recorded in pure_types. */
4699 4704
4700 static POINTER_TYPE * 4705 static POINTER_TYPE *
4701 pure_alloc (size, type) 4706 pure_alloc (size, type)
4702 size_t size; 4707 size_t size;
4703 int type; 4708 int type;
4718 #endif 4723 #endif
4719 } 4724 }
4720 #endif 4725 #endif
4721 4726
4722 again: 4727 again:
4723 result = ALIGN (purebeg + pure_bytes_used, alignment); 4728 if (type >= 0)
4724 pure_bytes_used = ((char *)result - (char *)purebeg) + size; 4729 {
4730 /* Allocate space for a Lisp object from the beginning of the free
4731 space with taking account of alignment. */
4732 result = ALIGN (purebeg + pure_bytes_used_lisp, alignment);
4733 pure_bytes_used_lisp = ((char *)result - (char *)purebeg) + size;
4734 }
4735 else
4736 {
4737 /* Allocate space for a non-Lisp object from the end of the free
4738 space. */
4739 pure_bytes_used_non_lisp += size;
4740 result = purebeg + pure_size - pure_bytes_used_non_lisp;
4741 }
4742 pure_bytes_used = pure_bytes_used_lisp + pure_bytes_used_non_lisp;
4725 4743
4726 if (pure_bytes_used <= pure_size) 4744 if (pure_bytes_used <= pure_size)
4727 return result; 4745 return result;
4728 4746
4729 /* Don't allocate a large amount here, 4747 /* Don't allocate a large amount here,
4731 might not be usable. */ 4749 might not be usable. */
4732 purebeg = (char *) xmalloc (10000); 4750 purebeg = (char *) xmalloc (10000);
4733 pure_size = 10000; 4751 pure_size = 10000;
4734 pure_bytes_used_before_overflow += pure_bytes_used - size; 4752 pure_bytes_used_before_overflow += pure_bytes_used - size;
4735 pure_bytes_used = 0; 4753 pure_bytes_used = 0;
4754 pure_bytes_used_lisp = pure_bytes_used_non_lisp = 0;
4736 goto again; 4755 goto again;
4737 } 4756 }
4738 4757
4739 4758
4740 /* Print a warning if PURESIZE is too small. */ 4759 /* Print a warning if PURESIZE is too small. */
6223 { 6242 {
6224 /* Used to do Vpurify_flag = Qt here, but Qt isn't set up yet! */ 6243 /* Used to do Vpurify_flag = Qt here, but Qt isn't set up yet! */
6225 purebeg = PUREBEG; 6244 purebeg = PUREBEG;
6226 pure_size = PURESIZE; 6245 pure_size = PURESIZE;
6227 pure_bytes_used = 0; 6246 pure_bytes_used = 0;
6247 pure_bytes_used_lisp = pure_bytes_used_non_lisp = 0;
6228 pure_bytes_used_before_overflow = 0; 6248 pure_bytes_used_before_overflow = 0;
6229 6249
6230 /* Initialize the list of free aligned blocks. */ 6250 /* Initialize the list of free aligned blocks. */
6231 free_ablock = NULL; 6251 free_ablock = NULL;
6232 6252