aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorStefan Monnier2007-09-29 20:19:41 +0000
committerStefan Monnier2007-09-29 20:19:41 +0000
commit9c545a55349f4edc19da0fa54e1e3f822ce04b61 (patch)
tree9abceeaad52af3ab04765b1430e282919bc94c25 /src/alloc.c
parentdafc79fa1bc62a089e613b5f9753df3789bdfce2 (diff)
downloademacs-9c545a55349f4edc19da0fa54e1e3f822ce04b61.tar.gz
emacs-9c545a55349f4edc19da0fa54e1e3f822ce04b61.zip
(enum mem_type): Replace all vector subtypes -> MEM_TYPE_VECTORLIKE.
(allocate_vectorlike): Remove type argument. Adjust callers. (live_vector_p, mark_maybe_pointer, valid_lisp_object_p): Only handle the one remaining MEM_TYPE_VECTORLIKE. (mark_terminal): Remove left-over declaration.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c54
1 files changed, 18 insertions, 36 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 245716fe06c..0d64bf66663 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -342,7 +342,6 @@ Lisp_Object Vgc_elapsed; /* accumulated elapsed time in GC */
342EMACS_INT gcs_done; /* accumulated GCs */ 342EMACS_INT gcs_done; /* accumulated GCs */
343 343
344static void mark_buffer P_ ((Lisp_Object)); 344static void mark_buffer P_ ((Lisp_Object));
345static void mark_terminal P_((struct terminal *t));
346static void mark_terminals P_ ((void)); 345static void mark_terminals P_ ((void));
347extern void mark_kboards P_ ((void)); 346extern void mark_kboards P_ ((void));
348extern void mark_ttys P_ ((void)); 347extern void mark_ttys P_ ((void));
@@ -377,15 +376,11 @@ enum mem_type
377 MEM_TYPE_MISC, 376 MEM_TYPE_MISC,
378 MEM_TYPE_SYMBOL, 377 MEM_TYPE_SYMBOL,
379 MEM_TYPE_FLOAT, 378 MEM_TYPE_FLOAT,
380 /* Keep the following vector-like types together, with 379 /* We used to keep separate mem_types for subtypes of vectors such as
381 MEM_TYPE_WINDOW being the last, and MEM_TYPE_VECTOR the 380 process, hash_table, frame, terminal, and window, but we never made
382 first. Or change the code of live_vector_p, for instance. */ 381 use of the distinction, so it only caused source-code complexity
383 MEM_TYPE_VECTOR, 382 and runtime slowdown. Minor but pointless. */
384 MEM_TYPE_PROCESS, 383 MEM_TYPE_VECTORLIKE
385 MEM_TYPE_HASH_TABLE,
386 MEM_TYPE_FRAME,
387 MEM_TYPE_TERMINAL,
388 MEM_TYPE_WINDOW
389}; 384};
390 385
391static POINTER_TYPE *lisp_align_malloc P_ ((size_t, enum mem_type)); 386static POINTER_TYPE *lisp_align_malloc P_ ((size_t, enum mem_type));
@@ -472,7 +467,7 @@ static struct mem_node mem_z;
472#define MEM_NIL &mem_z 467#define MEM_NIL &mem_z
473 468
474static POINTER_TYPE *lisp_malloc P_ ((size_t, enum mem_type)); 469static POINTER_TYPE *lisp_malloc P_ ((size_t, enum mem_type));
475static struct Lisp_Vector *allocate_vectorlike P_ ((EMACS_INT, enum mem_type)); 470static struct Lisp_Vector *allocate_vectorlike P_ ((EMACS_INT));
476static void lisp_free P_ ((POINTER_TYPE *)); 471static void lisp_free P_ ((POINTER_TYPE *));
477static void mark_stack P_ ((void)); 472static void mark_stack P_ ((void));
478static int live_vector_p P_ ((struct mem_node *, void *)); 473static int live_vector_p P_ ((struct mem_node *, void *));
@@ -2915,9 +2910,8 @@ int n_vectors;
2915 with room for LEN Lisp_Objects. */ 2910 with room for LEN Lisp_Objects. */
2916 2911
2917static struct Lisp_Vector * 2912static struct Lisp_Vector *
2918allocate_vectorlike (len, type) 2913allocate_vectorlike (len)
2919 EMACS_INT len; 2914 EMACS_INT len;
2920 enum mem_type type;
2921{ 2915{
2922 struct Lisp_Vector *p; 2916 struct Lisp_Vector *p;
2923 size_t nbytes; 2917 size_t nbytes;
@@ -2935,7 +2929,7 @@ allocate_vectorlike (len, type)
2935 /* eassert (!handling_signal); */ 2929 /* eassert (!handling_signal); */
2936 2930
2937 nbytes = sizeof *p + (len - 1) * sizeof p->contents[0]; 2931 nbytes = sizeof *p + (len - 1) * sizeof p->contents[0];
2938 p = (struct Lisp_Vector *) lisp_malloc (nbytes, type); 2932 p = (struct Lisp_Vector *) lisp_malloc (nbytes, MEM_TYPE_VECTORLIKE);
2939 2933
2940#ifdef DOUG_LEA_MALLOC 2934#ifdef DOUG_LEA_MALLOC
2941 /* Back to a reasonable maximum of mmap'ed areas. */ 2935 /* Back to a reasonable maximum of mmap'ed areas. */
@@ -2961,7 +2955,7 @@ struct Lisp_Vector *
2961allocate_vector (nslots) 2955allocate_vector (nslots)
2962 EMACS_INT nslots; 2956 EMACS_INT nslots;
2963{ 2957{
2964 struct Lisp_Vector *v = allocate_vectorlike (nslots, MEM_TYPE_VECTOR); 2958 struct Lisp_Vector *v = allocate_vectorlike (nslots);
2965 v->size = nslots; 2959 v->size = nslots;
2966 return v; 2960 return v;
2967} 2961}
@@ -2973,7 +2967,7 @@ struct Lisp_Hash_Table *
2973allocate_hash_table () 2967allocate_hash_table ()
2974{ 2968{
2975 EMACS_INT len = VECSIZE (struct Lisp_Hash_Table); 2969 EMACS_INT len = VECSIZE (struct Lisp_Hash_Table);
2976 struct Lisp_Vector *v = allocate_vectorlike (len, MEM_TYPE_HASH_TABLE); 2970 struct Lisp_Vector *v = allocate_vectorlike (len);
2977 EMACS_INT i; 2971 EMACS_INT i;
2978 2972
2979 v->size = len; 2973 v->size = len;
@@ -2988,7 +2982,7 @@ struct window *
2988allocate_window () 2982allocate_window ()
2989{ 2983{
2990 EMACS_INT len = VECSIZE (struct window); 2984 EMACS_INT len = VECSIZE (struct window);
2991 struct Lisp_Vector *v = allocate_vectorlike (len, MEM_TYPE_WINDOW); 2985 struct Lisp_Vector *v = allocate_vectorlike (len);
2992 EMACS_INT i; 2986 EMACS_INT i;
2993 2987
2994 for (i = 0; i < len; ++i) 2988 for (i = 0; i < len; ++i)
@@ -3007,7 +3001,7 @@ allocate_terminal ()
3007 /* Size if we only count the actual Lisp_Object fields (which need to be 3001 /* Size if we only count the actual Lisp_Object fields (which need to be
3008 traced by the GC). */ 3002 traced by the GC). */
3009 EMACS_INT lisplen = PSEUDOVECSIZE (struct terminal, next_terminal); 3003 EMACS_INT lisplen = PSEUDOVECSIZE (struct terminal, next_terminal);
3010 struct Lisp_Vector *v = allocate_vectorlike (memlen, MEM_TYPE_TERMINAL); 3004 struct Lisp_Vector *v = allocate_vectorlike (memlen);
3011 EMACS_INT i; 3005 EMACS_INT i;
3012 Lisp_Object tmp, zero = make_number (0); 3006 Lisp_Object tmp, zero = make_number (0);
3013 3007
@@ -3025,7 +3019,7 @@ struct frame *
3025allocate_frame () 3019allocate_frame ()
3026{ 3020{
3027 EMACS_INT len = VECSIZE (struct frame); 3021 EMACS_INT len = VECSIZE (struct frame);
3028 struct Lisp_Vector *v = allocate_vectorlike (len, MEM_TYPE_FRAME); 3022 struct Lisp_Vector *v = allocate_vectorlike (len);
3029 EMACS_INT i; 3023 EMACS_INT i;
3030 3024
3031 for (i = 0; i < len; ++i) 3025 for (i = 0; i < len; ++i)
@@ -3043,7 +3037,7 @@ allocate_process ()
3043 /* Size if we only count the actual Lisp_Object fields (which need to be 3037 /* Size if we only count the actual Lisp_Object fields (which need to be
3044 traced by the GC). */ 3038 traced by the GC). */
3045 EMACS_INT lisplen = PSEUDOVECSIZE (struct Lisp_Process, pid); 3039 EMACS_INT lisplen = PSEUDOVECSIZE (struct Lisp_Process, pid);
3046 struct Lisp_Vector *v = allocate_vectorlike (memlen, MEM_TYPE_PROCESS); 3040 struct Lisp_Vector *v = allocate_vectorlike (memlen);
3047 EMACS_INT i; 3041 EMACS_INT i;
3048 3042
3049 for (i = 0; i < lisplen; ++i) 3043 for (i = 0; i < lisplen; ++i)
@@ -3058,7 +3052,7 @@ struct Lisp_Vector *
3058allocate_other_vector (len) 3052allocate_other_vector (len)
3059 EMACS_INT len; 3053 EMACS_INT len;
3060{ 3054{
3061 struct Lisp_Vector *v = allocate_vectorlike (len, MEM_TYPE_VECTOR); 3055 struct Lisp_Vector *v = allocate_vectorlike (len);
3062 EMACS_INT i; 3056 EMACS_INT i;
3063 3057
3064 for (i = 0; i < len; ++i) 3058 for (i = 0; i < len; ++i)
@@ -4112,9 +4106,7 @@ live_vector_p (m, p)
4112 struct mem_node *m; 4106 struct mem_node *m;
4113 void *p; 4107 void *p;
4114{ 4108{
4115 return (p == m->start 4109 return (p == m->start && m->type == MEM_TYPE_VECTORLIKE);
4116 && m->type >= MEM_TYPE_VECTOR
4117 && m->type <= MEM_TYPE_WINDOW);
4118} 4110}
4119 4111
4120 4112
@@ -4312,12 +4304,7 @@ mark_maybe_pointer (p)
4312 XSETFLOAT (obj, p); 4304 XSETFLOAT (obj, p);
4313 break; 4305 break;
4314 4306
4315 case MEM_TYPE_VECTOR: 4307 case MEM_TYPE_VECTORLIKE:
4316 case MEM_TYPE_PROCESS:
4317 case MEM_TYPE_HASH_TABLE:
4318 case MEM_TYPE_FRAME:
4319 case MEM_TYPE_TERMINAL:
4320 case MEM_TYPE_WINDOW:
4321 if (live_vector_p (m, p)) 4308 if (live_vector_p (m, p))
4322 { 4309 {
4323 Lisp_Object tem; 4310 Lisp_Object tem;
@@ -4717,12 +4704,7 @@ valid_lisp_object_p (obj)
4717 case MEM_TYPE_FLOAT: 4704 case MEM_TYPE_FLOAT:
4718 return live_float_p (m, p); 4705 return live_float_p (m, p);
4719 4706
4720 case MEM_TYPE_VECTOR: 4707 case MEM_TYPE_VECTORLIKE:
4721 case MEM_TYPE_PROCESS:
4722 case MEM_TYPE_HASH_TABLE:
4723 case MEM_TYPE_FRAME:
4724 case MEM_TYPE_TERMINAL:
4725 case MEM_TYPE_WINDOW:
4726 return live_vector_p (m, p); 4708 return live_vector_p (m, p);
4727 4709
4728 default: 4710 default: