aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/alloc.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 4b3fa4d7e69..55dc9f4e6de 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -289,10 +289,18 @@ static size_t pure_bytes_used_before_overflow;
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
294EMACS_INT pure_bytes_used; 294EMACS_INT pure_bytes_used;
295 295
296/* Index in pure at which next pure Lisp object will be allocated.. */
297
298static EMACS_INT pure_bytes_used_lisp;
299
300/* Number of bytes allocated for non-Lisp objects in pure storage. */
301
302static EMACS_INT pure_bytes_used_non_lisp;
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
@@ -4692,10 +4700,7 @@ valid_lisp_object_p (obj)
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
4700static POINTER_TYPE * 4705static POINTER_TYPE *
4701pure_alloc (size, type) 4706pure_alloc (size, type)
@@ -4720,8 +4725,21 @@ pure_alloc (size, type)
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;
@@ -4733,6 +4751,7 @@ pure_alloc (size, type)
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
@@ -6225,6 +6244,7 @@ init_alloc_once ()
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. */