aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorKenichi Handa2013-04-05 23:17:55 +0900
committerKenichi Handa2013-04-05 23:17:55 +0900
commitb7a6f9f7919b7fc0871ae768b58f8e746aa7dd9f (patch)
treef32c8cce416e346d2953f063a0f22e95382cf57e /src/alloc.c
parent251e91474c91e16b101502c2ed7c05fc13e4ecea (diff)
parent73931ad14ad7a51d91f10b19ae9ca8cadb256916 (diff)
downloademacs-b7a6f9f7919b7fc0871ae768b58f8e746aa7dd9f.tar.gz
emacs-b7a6f9f7919b7fc0871ae768b58f8e746aa7dd9f.zip
merge trunk
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c118
1 files changed, 42 insertions, 76 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 5e30c1b20ad..7a56c78e2ba 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -323,20 +323,7 @@ static void *min_heap_address, *max_heap_address;
323static struct mem_node mem_z; 323static struct mem_node mem_z;
324#define MEM_NIL &mem_z 324#define MEM_NIL &mem_z
325 325
326static struct Lisp_Vector *allocate_vectorlike (ptrdiff_t);
327static void lisp_free (void *);
328static void mark_stack (void);
329static bool live_vector_p (struct mem_node *, void *);
330static bool live_buffer_p (struct mem_node *, void *);
331static bool live_string_p (struct mem_node *, void *);
332static bool live_cons_p (struct mem_node *, void *);
333static bool live_symbol_p (struct mem_node *, void *);
334static bool live_float_p (struct mem_node *, void *);
335static bool live_misc_p (struct mem_node *, void *);
336static void mark_maybe_object (Lisp_Object);
337static void mark_memory (void *, void *);
338#if GC_MARK_STACK || defined GC_MALLOC_CHECK 326#if GC_MARK_STACK || defined GC_MALLOC_CHECK
339static void mem_init (void);
340static struct mem_node *mem_insert (void *, void *, enum mem_type); 327static struct mem_node *mem_insert (void *, void *, enum mem_type);
341static void mem_insert_fixup (struct mem_node *); 328static void mem_insert_fixup (struct mem_node *);
342static void mem_rotate_left (struct mem_node *); 329static void mem_rotate_left (struct mem_node *);
@@ -346,11 +333,6 @@ static void mem_delete_fixup (struct mem_node *);
346static struct mem_node *mem_find (void *); 333static struct mem_node *mem_find (void *);
347#endif 334#endif
348 335
349
350#if GC_MARK_STACK == GC_MARK_STACK_CHECK_GCPROS
351static void check_gcpros (void);
352#endif
353
354#endif /* GC_MARK_STACK || GC_MALLOC_CHECK */ 336#endif /* GC_MARK_STACK || GC_MALLOC_CHECK */
355 337
356#ifndef DEADP 338#ifndef DEADP
@@ -3344,56 +3326,50 @@ free_misc (Lisp_Object misc)
3344 total_free_markers++; 3326 total_free_markers++;
3345} 3327}
3346 3328
3329/* Verify properties of Lisp_Save_Value's representation
3330 that are assumed here and elsewhere. */
3331
3332verify (SAVE_UNUSED == 0);
3333verify ((SAVE_INTEGER | SAVE_POINTER | SAVE_OBJECT) >> SAVE_SLOT_BITS == 0);
3334
3347/* Return a Lisp_Save_Value object with the data saved according to 3335/* Return a Lisp_Save_Value object with the data saved according to
3348 FMT. Format specifiers are `i' for an integer, `p' for a pointer 3336 DATA_TYPE. DATA_TYPE should be one of SAVE_TYPE_INT_INT, etc. */
3349 and `o' for Lisp_Object. Up to 4 objects can be specified. */
3350 3337
3351Lisp_Object 3338Lisp_Object
3352make_save_value (const char *fmt, ...) 3339make_save_value (enum Lisp_Save_Type save_type, ...)
3353{ 3340{
3354 va_list ap; 3341 va_list ap;
3355 int len = strlen (fmt); 3342 int i;
3356 Lisp_Object val = allocate_misc (Lisp_Misc_Save_Value); 3343 Lisp_Object val = allocate_misc (Lisp_Misc_Save_Value);
3357 struct Lisp_Save_Value *p = XSAVE_VALUE (val); 3344 struct Lisp_Save_Value *p = XSAVE_VALUE (val);
3358 3345
3359 eassert (0 < len && len < 5); 3346 eassert (0 < save_type
3360 va_start (ap, fmt); 3347 && (save_type < 1 << (SAVE_TYPE_BITS - 1)
3361 3348 || save_type == SAVE_TYPE_MEMORY));
3362#define INITX(index) \ 3349 p->save_type = save_type;
3363 do { \ 3350 va_start (ap, save_type);
3364 if (len <= index) \ 3351 save_type &= ~ (1 << (SAVE_TYPE_BITS - 1));
3365 p->type ## index = SAVE_UNUSED; \ 3352
3366 else \ 3353 for (i = 0; save_type; i++, save_type >>= SAVE_SLOT_BITS)
3367 { \ 3354 switch (save_type & ((1 << SAVE_SLOT_BITS) - 1))
3368 if (fmt[index] == 'i') \ 3355 {
3369 { \ 3356 case SAVE_POINTER:
3370 p->type ## index = SAVE_INTEGER; \ 3357 p->data[i].pointer = va_arg (ap, void *);
3371 p->data[index].integer = va_arg (ap, ptrdiff_t); \ 3358 break;
3372 } \
3373 else if (fmt[index] == 'p') \
3374 { \
3375 p->type ## index = SAVE_POINTER; \
3376 p->data[index].pointer = va_arg (ap, void *); \
3377 } \
3378 else if (fmt[index] == 'o') \
3379 { \
3380 p->type ## index = SAVE_OBJECT; \
3381 p->data[index].object = va_arg (ap, Lisp_Object); \
3382 } \
3383 else \
3384 emacs_abort (); \
3385 } \
3386 } while (0)
3387 3359
3388 INITX (0); 3360 case SAVE_INTEGER:
3389 INITX (1); 3361 p->data[i].integer = va_arg (ap, ptrdiff_t);
3390 INITX (2); 3362 break;
3391 INITX (3);
3392 3363
3393#undef INITX 3364 case SAVE_OBJECT:
3365 p->data[i].object = va_arg (ap, Lisp_Object);
3366 break;
3367
3368 default:
3369 emacs_abort ();
3370 }
3394 3371
3395 va_end (ap); 3372 va_end (ap);
3396 p->area = 0;
3397 return val; 3373 return val;
3398} 3374}
3399 3375
@@ -3404,11 +3380,8 @@ make_save_pointer (void *pointer)
3404{ 3380{
3405 Lisp_Object val = allocate_misc (Lisp_Misc_Save_Value); 3381 Lisp_Object val = allocate_misc (Lisp_Misc_Save_Value);
3406 struct Lisp_Save_Value *p = XSAVE_VALUE (val); 3382 struct Lisp_Save_Value *p = XSAVE_VALUE (val);
3407 3383 p->save_type = SAVE_POINTER;
3408 p->area = 0;
3409 p->type0 = SAVE_POINTER;
3410 p->data[0].pointer = pointer; 3384 p->data[0].pointer = pointer;
3411 p->type1 = p->type2 = p->type3 = SAVE_UNUSED;
3412 return val; 3385 return val;
3413} 3386}
3414 3387
@@ -5837,14 +5810,13 @@ mark_object (Lisp_Object arg)
5837 case PVEC_WINDOW: 5810 case PVEC_WINDOW:
5838 { 5811 {
5839 struct window *w = (struct window *) ptr; 5812 struct window *w = (struct window *) ptr;
5840 bool leaf = NILP (w->hchild) && NILP (w->vchild);
5841 5813
5842 mark_vectorlike (ptr); 5814 mark_vectorlike (ptr);
5843 5815
5844 /* Mark glyphs for leaf windows. Marking window 5816 /* Mark glyph matrices, if any. Marking window
5845 matrices is sufficient because frame matrices 5817 matrices is sufficient because frame matrices
5846 use the same glyph memory. */ 5818 use the same glyph memory. */
5847 if (leaf && w->current_matrix) 5819 if (w->current_matrix)
5848 { 5820 {
5849 mark_glyph_matrix (w->current_matrix); 5821 mark_glyph_matrix (w->current_matrix);
5850 mark_glyph_matrix (w->desired_matrix); 5822 mark_glyph_matrix (w->desired_matrix);
@@ -5976,12 +5948,11 @@ mark_object (Lisp_Object arg)
5976 case Lisp_Misc_Save_Value: 5948 case Lisp_Misc_Save_Value:
5977 XMISCANY (obj)->gcmarkbit = 1; 5949 XMISCANY (obj)->gcmarkbit = 1;
5978 { 5950 {
5979 register struct Lisp_Save_Value *ptr = XSAVE_VALUE (obj); 5951 struct Lisp_Save_Value *ptr = XSAVE_VALUE (obj);
5980 /* If `area' is nonzero, `data[0].pointer' is the address 5952 /* If `save_type' is zero, `data[0].pointer' is the address
5981 of a memory area containing `data[1].integer' potential 5953 of a memory area containing `data[1].integer' potential
5982 Lisp_Objects. */ 5954 Lisp_Objects. */
5983#if GC_MARK_STACK 5955 if (GC_MARK_STACK && ptr->save_type == SAVE_TYPE_MEMORY)
5984 if (ptr->area)
5985 { 5956 {
5986 Lisp_Object *p = ptr->data[0].pointer; 5957 Lisp_Object *p = ptr->data[0].pointer;
5987 ptrdiff_t nelt; 5958 ptrdiff_t nelt;
@@ -5989,17 +5960,12 @@ mark_object (Lisp_Object arg)
5989 mark_maybe_object (*p); 5960 mark_maybe_object (*p);
5990 } 5961 }
5991 else 5962 else
5992#endif /* GC_MARK_STACK */
5993 { 5963 {
5994 /* Find Lisp_Objects in `data[N]' slots and mark them. */ 5964 /* Find Lisp_Objects in `data[N]' slots and mark them. */
5995 if (ptr->type0 == SAVE_OBJECT) 5965 int i;
5996 mark_object (ptr->data[0].object); 5966 for (i = 0; i < SAVE_VALUE_SLOTS; i++)
5997 if (ptr->type1 == SAVE_OBJECT) 5967 if (save_type (ptr, i) == SAVE_OBJECT)
5998 mark_object (ptr->data[1].object); 5968 mark_object (ptr->data[i].object);
5999 if (ptr->type2 == SAVE_OBJECT)
6000 mark_object (ptr->data[2].object);
6001 if (ptr->type3 == SAVE_OBJECT)
6002 mark_object (ptr->data[3].object);
6003 } 5969 }
6004 } 5970 }
6005 break; 5971 break;