aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitry Antipov2012-08-01 12:49:28 +0400
committerDmitry Antipov2012-08-01 12:49:28 +0400
commitd8a05828fd9f78c6cadddd8b47b53d83833c3917 (patch)
treee79a8e7e0a0abc277d5f928835abb0b64d7dcae7 /src
parent015a2738eb575f9dc07ea5e589eb88c8e071930a (diff)
downloademacs-d8a05828fd9f78c6cadddd8b47b53d83833c3917.tar.gz
emacs-d8a05828fd9f78c6cadddd8b47b53d83833c3917.zip
Use INTERNAL_FIELD for conses and overlays.
* src/lisp.h (struct Lisp_Cons): Use INTERNAL_FIELD. Remove obsolete comment. (MVAR): New macro. (struct Lisp_Overlay): Use INTERNAL_FIELD. * src/alloc.c, src/buffer.c, src/buffer.h, src/fns.c: Adjust users. * admin/coccinelle/overlay.cocci: Semantic patch to replace direct access to Lisp_Object members of struct Lisp_Overlay to MVAR.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog9
-rw-r--r--src/alloc.c20
-rw-r--r--src/buffer.c29
-rw-r--r--src/buffer.h6
-rw-r--r--src/fns.c4
-rw-r--r--src/lisp.h31
6 files changed, 60 insertions, 39 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 3bb9c2b4eef..a6913d1ad78 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,14 @@
12012-08-01 Dmitry Antipov <dmantipov@yandex.ru> 12012-08-01 Dmitry Antipov <dmantipov@yandex.ru>
2 2
3 Use INTERNAL_FIELD for conses and overlays.
4 * lisp.h (struct Lisp_Cons): Use INTERNAL_FIELD.
5 Remove obsolete comment.
6 (MVAR): New macro.
7 (struct Lisp_Overlay): Use INTERNAL_FIELD.
8 * alloc.c, buffer.c, buffer.h, fns.c: Adjust users.
9
102012-08-01 Dmitry Antipov <dmantipov@yandex.ru>
11
3 Use INTERNAL_FIELD for symbols. 12 Use INTERNAL_FIELD for symbols.
4 * lisp.h (SVAR): New macro. Adjust users. 13 * lisp.h (SVAR): New macro. Adjust users.
5 * alloc.c, bytecode.c, cmds.c, data.c, doc.c, eval.c: 14 * alloc.c, bytecode.c, cmds.c, data.c, doc.c, eval.c:
diff --git a/src/alloc.c b/src/alloc.c
index 8207f022a12..2d5149a6772 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -2686,7 +2686,7 @@ free_cons (struct Lisp_Cons *ptr)
2686{ 2686{
2687 ptr->u.chain = cons_free_list; 2687 ptr->u.chain = cons_free_list;
2688#if GC_MARK_STACK 2688#if GC_MARK_STACK
2689 ptr->car = Vdead; 2689 CVAR (ptr, car) = Vdead;
2690#endif 2690#endif
2691 cons_free_list = ptr; 2691 cons_free_list = ptr;
2692 consing_since_gc -= sizeof *ptr; 2692 consing_since_gc -= sizeof *ptr;
@@ -4295,7 +4295,7 @@ live_cons_p (struct mem_node *m, void *p)
4295 && offset < (CONS_BLOCK_SIZE * sizeof b->conses[0]) 4295 && offset < (CONS_BLOCK_SIZE * sizeof b->conses[0])
4296 && (b != cons_block 4296 && (b != cons_block
4297 || offset / sizeof b->conses[0] < cons_block_index) 4297 || offset / sizeof b->conses[0] < cons_block_index)
4298 && !EQ (((struct Lisp_Cons *) p)->car, Vdead)); 4298 && !EQ (CVAR ((struct Lisp_Cons *) p, car), Vdead));
4299 } 4299 }
4300 else 4300 else
4301 return 0; 4301 return 0;
@@ -5837,9 +5837,9 @@ mark_overlay (struct Lisp_Overlay *ptr)
5837 for (; ptr && !ptr->gcmarkbit; ptr = ptr->next) 5837 for (; ptr && !ptr->gcmarkbit; ptr = ptr->next)
5838 { 5838 {
5839 ptr->gcmarkbit = 1; 5839 ptr->gcmarkbit = 1;
5840 mark_object (ptr->start); 5840 mark_object (MVAR (ptr, start));
5841 mark_object (ptr->end); 5841 mark_object (MVAR (ptr, end));
5842 mark_object (ptr->plist); 5842 mark_object (MVAR (ptr, plist));
5843 } 5843 }
5844} 5844}
5845 5845
@@ -6169,14 +6169,14 @@ mark_object (Lisp_Object arg)
6169 CHECK_ALLOCATED_AND_LIVE (live_cons_p); 6169 CHECK_ALLOCATED_AND_LIVE (live_cons_p);
6170 CONS_MARK (ptr); 6170 CONS_MARK (ptr);
6171 /* If the cdr is nil, avoid recursion for the car. */ 6171 /* If the cdr is nil, avoid recursion for the car. */
6172 if (EQ (ptr->u.cdr, Qnil)) 6172 if (EQ (CVAR (ptr, u.cdr), Qnil))
6173 { 6173 {
6174 obj = ptr->car; 6174 obj = CVAR (ptr, car);
6175 cdr_count = 0; 6175 cdr_count = 0;
6176 goto loop; 6176 goto loop;
6177 } 6177 }
6178 mark_object (ptr->car); 6178 mark_object (CVAR (ptr, car));
6179 obj = ptr->u.cdr; 6179 obj = CVAR (ptr, u.cdr);
6180 cdr_count++; 6180 cdr_count++;
6181 if (cdr_count == mark_object_loop_halt) 6181 if (cdr_count == mark_object_loop_halt)
6182 abort (); 6182 abort ();
@@ -6325,7 +6325,7 @@ gc_sweep (void)
6325 cblk->conses[pos].u.chain = cons_free_list; 6325 cblk->conses[pos].u.chain = cons_free_list;
6326 cons_free_list = &cblk->conses[pos]; 6326 cons_free_list = &cblk->conses[pos];
6327#if GC_MARK_STACK 6327#if GC_MARK_STACK
6328 cons_free_list->car = Vdead; 6328 CVAR (cons_free_list, car) = Vdead;
6329#endif 6329#endif
6330 } 6330 }
6331 else 6331 else
diff --git a/src/buffer.c b/src/buffer.c
index e70360f5173..8b7f524e27a 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -417,17 +417,17 @@ copy_overlays (struct buffer *b, struct Lisp_Overlay *list)
417 Lisp_Object overlay, start, end; 417 Lisp_Object overlay, start, end;
418 struct Lisp_Marker *m; 418 struct Lisp_Marker *m;
419 419
420 eassert (MARKERP (list->start)); 420 eassert (MARKERP (MVAR (list, start)));
421 m = XMARKER (list->start); 421 m = XMARKER (MVAR (list, start));
422 start = build_marker (b, m->charpos, m->bytepos); 422 start = build_marker (b, m->charpos, m->bytepos);
423 XMARKER (start)->insertion_type = m->insertion_type; 423 XMARKER (start)->insertion_type = m->insertion_type;
424 424
425 eassert (MARKERP (list->end)); 425 eassert (MARKERP (MVAR (list, end)));
426 m = XMARKER (list->end); 426 m = XMARKER (MVAR (list, end));
427 end = build_marker (b, m->charpos, m->bytepos); 427 end = build_marker (b, m->charpos, m->bytepos);
428 XMARKER (end)->insertion_type = m->insertion_type; 428 XMARKER (end)->insertion_type = m->insertion_type;
429 429
430 overlay = build_overlay (start, end, Fcopy_sequence (list->plist)); 430 overlay = build_overlay (start, end, Fcopy_sequence (MVAR (list, plist)));
431 if (tail) 431 if (tail)
432 tail = tail->next = XOVERLAY (overlay); 432 tail = tail->next = XOVERLAY (overlay);
433 else 433 else
@@ -657,10 +657,11 @@ CLONE nil means the indirect buffer's state is reset to default values. */)
657static void 657static void
658drop_overlay (struct buffer *b, struct Lisp_Overlay *ov) 658drop_overlay (struct buffer *b, struct Lisp_Overlay *ov)
659{ 659{
660 eassert (b == XBUFFER (Fmarker_buffer (ov->start))); 660 eassert (b == XBUFFER (Fmarker_buffer (MVAR (ov, start))));
661 modify_overlay (b, marker_position (ov->start), marker_position (ov->end)); 661 modify_overlay (b, marker_position (MVAR (ov, start)),
662 Fset_marker (ov->start, Qnil, Qnil); 662 marker_position (MVAR (ov, end)));
663 Fset_marker (ov->end, Qnil, Qnil); 663 Fset_marker (MVAR (ov, start), Qnil, Qnil);
664 Fset_marker (MVAR (ov, end), Qnil, Qnil);
664 665
665} 666}
666 667
@@ -3886,7 +3887,7 @@ OVERLAY. */)
3886{ 3887{
3887 CHECK_OVERLAY (overlay); 3888 CHECK_OVERLAY (overlay);
3888 3889
3889 return Fcopy_sequence (XOVERLAY (overlay)->plist); 3890 return Fcopy_sequence (MVAR (XOVERLAY (overlay), plist));
3890} 3891}
3891 3892
3892 3893
@@ -4062,7 +4063,7 @@ DEFUN ("overlay-get", Foverlay_get, Soverlay_get, 2, 2, 0,
4062 (Lisp_Object overlay, Lisp_Object prop) 4063 (Lisp_Object overlay, Lisp_Object prop)
4063{ 4064{
4064 CHECK_OVERLAY (overlay); 4065 CHECK_OVERLAY (overlay);
4065 return lookup_char_property (XOVERLAY (overlay)->plist, prop, 0); 4066 return lookup_char_property (MVAR (XOVERLAY (overlay), plist), prop, 0);
4066} 4067}
4067 4068
4068DEFUN ("overlay-put", Foverlay_put, Soverlay_put, 3, 3, 0, 4069DEFUN ("overlay-put", Foverlay_put, Soverlay_put, 3, 3, 0,
@@ -4077,7 +4078,7 @@ VALUE will be returned.*/)
4077 4078
4078 buffer = Fmarker_buffer (OVERLAY_START (overlay)); 4079 buffer = Fmarker_buffer (OVERLAY_START (overlay));
4079 4080
4080 for (tail = XOVERLAY (overlay)->plist; 4081 for (tail = MVAR (XOVERLAY (overlay), plist);
4081 CONSP (tail) && CONSP (XCDR (tail)); 4082 CONSP (tail) && CONSP (XCDR (tail));
4082 tail = XCDR (XCDR (tail))) 4083 tail = XCDR (XCDR (tail)))
4083 if (EQ (XCAR (tail), prop)) 4084 if (EQ (XCAR (tail), prop))
@@ -4088,8 +4089,8 @@ VALUE will be returned.*/)
4088 } 4089 }
4089 /* It wasn't in the list, so add it to the front. */ 4090 /* It wasn't in the list, so add it to the front. */
4090 changed = !NILP (value); 4091 changed = !NILP (value);
4091 XOVERLAY (overlay)->plist 4092 MVAR (XOVERLAY (overlay), plist)
4092 = Fcons (prop, Fcons (value, XOVERLAY (overlay)->plist)); 4093 = Fcons (prop, Fcons (value, MVAR (XOVERLAY (overlay), plist)));
4093 found: 4094 found:
4094 if (! NILP (buffer)) 4095 if (! NILP (buffer))
4095 { 4096 {
diff --git a/src/buffer.h b/src/buffer.h
index b9a2c9c7dce..cf571e06b53 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -986,15 +986,15 @@ BUF_FETCH_MULTIBYTE_CHAR (struct buffer *buf, ptrdiff_t pos)
986 986
987/* Return the marker that stands for where OV starts in the buffer. */ 987/* Return the marker that stands for where OV starts in the buffer. */
988 988
989#define OVERLAY_START(OV) (XOVERLAY (OV)->start) 989#define OVERLAY_START(OV) MVAR (XOVERLAY (OV), start)
990 990
991/* Return the marker that stands for where OV ends in the buffer. */ 991/* Return the marker that stands for where OV ends in the buffer. */
992 992
993#define OVERLAY_END(OV) (XOVERLAY (OV)->end) 993#define OVERLAY_END(OV) MVAR (XOVERLAY (OV), end)
994 994
995/* Return the plist of overlay OV. */ 995/* Return the plist of overlay OV. */
996 996
997#define OVERLAY_PLIST(OV) XOVERLAY ((OV))->plist 997#define OVERLAY_PLIST(OV) MVAR (XOVERLAY (OV), plist)
998 998
999/* Return the actual buffer position for the marker P. 999/* Return the actual buffer position for the marker P.
1000 We assume you know which buffer it's pointing into. */ 1000 We assume you know which buffer it's pointing into. */
diff --git a/src/fns.c b/src/fns.c
index 0ff2877ea5e..a8c8cb283b0 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -2053,8 +2053,8 @@ internal_equal (register Lisp_Object o1, register Lisp_Object o2, int depth, int
2053 || !internal_equal (OVERLAY_END (o1), OVERLAY_END (o2), 2053 || !internal_equal (OVERLAY_END (o1), OVERLAY_END (o2),
2054 depth + 1, props)) 2054 depth + 1, props))
2055 return 0; 2055 return 0;
2056 o1 = XOVERLAY (o1)->plist; 2056 o1 = MVAR (XOVERLAY (o1), plist);
2057 o2 = XOVERLAY (o2)->plist; 2057 o2 = MVAR (XOVERLAY (o2), plist);
2058 goto tail_recurse; 2058 goto tail_recurse;
2059 } 2059 }
2060 if (MARKERP (o1)) 2060 if (MARKERP (o1))
diff --git a/src/lisp.h b/src/lisp.h
index 5e2195ce01d..2928f92df37 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -637,17 +637,22 @@ typedef struct interval *INTERVAL;
637#define CHECK_STRING_OR_BUFFER(x) \ 637#define CHECK_STRING_OR_BUFFER(x) \
638 CHECK_TYPE (STRINGP (x) || BUFFERP (x), Qbuffer_or_string_p, x) 638 CHECK_TYPE (STRINGP (x) || BUFFERP (x), Qbuffer_or_string_p, x)
639 639
640 640/* Most code should use this macro to
641/* In a cons, the markbit of the car is the gc mark bit */ 641 access Lisp fields in struct Lisp_Cons. */
642
643#define CVAR(cons, field) ((cons)->INTERNAL_FIELD (field))
642 644
643struct Lisp_Cons 645struct Lisp_Cons
644 { 646 {
645 /* Please do not use the names of these elements in code other 647 /* Car of this cons cell. */
646 than the core lisp implementation. Use XCAR and XCDR below. */ 648 Lisp_Object INTERNAL_FIELD (car);
647 Lisp_Object car; 649
648 union 650 union
649 { 651 {
650 Lisp_Object cdr; 652 /* Cdr of this cons cell. */
653 Lisp_Object INTERNAL_FIELD (cdr);
654
655 /* Used to chain conses on a free list. */
651 struct Lisp_Cons *chain; 656 struct Lisp_Cons *chain;
652 } u; 657 } u;
653 }; 658 };
@@ -659,8 +664,8 @@ struct Lisp_Cons
659 fields are not accessible as lvalues. (What if we want to switch to 664 fields are not accessible as lvalues. (What if we want to switch to
660 a copying collector someday? Cached cons cell field addresses may be 665 a copying collector someday? Cached cons cell field addresses may be
661 invalidated at arbitrary points.) */ 666 invalidated at arbitrary points.) */
662#define XCAR_AS_LVALUE(c) (XCONS ((c))->car) 667#define XCAR_AS_LVALUE(c) (CVAR (XCONS (c), car))
663#define XCDR_AS_LVALUE(c) (XCONS ((c))->u.cdr) 668#define XCDR_AS_LVALUE(c) (CVAR (XCONS (c), u.cdr))
664 669
665/* Use these from normal code. */ 670/* Use these from normal code. */
666#define XCAR(c) LISP_MAKE_RVALUE (XCAR_AS_LVALUE (c)) 671#define XCAR(c) LISP_MAKE_RVALUE (XCAR_AS_LVALUE (c))
@@ -1261,7 +1266,11 @@ enum DEFAULT_HASH_SIZE { DEFAULT_HASH_SIZE = 65 };
1261 1266
1262#define DEFAULT_REHASH_SIZE 1.5 1267#define DEFAULT_REHASH_SIZE 1.5
1263 1268
1264 1269/* Most code should use this macro to access
1270 Lisp fields in a different misc objects. */
1271
1272#define MVAR(misc, field) ((misc)->INTERNAL_FIELD (field))
1273
1265/* These structures are used for various misc types. */ 1274/* These structures are used for various misc types. */
1266 1275
1267struct Lisp_Misc_Any /* Supertype of all Misc types. */ 1276struct Lisp_Misc_Any /* Supertype of all Misc types. */
@@ -1331,7 +1340,9 @@ struct Lisp_Overlay
1331 unsigned gcmarkbit : 1; 1340 unsigned gcmarkbit : 1;
1332 int spacer : 15; 1341 int spacer : 15;
1333 struct Lisp_Overlay *next; 1342 struct Lisp_Overlay *next;
1334 Lisp_Object start, end, plist; 1343 Lisp_Object INTERNAL_FIELD (start);
1344 Lisp_Object INTERNAL_FIELD (end);
1345 Lisp_Object INTERNAL_FIELD (plist);
1335 }; 1346 };
1336 1347
1337/* Hold a C pointer for later use. 1348/* Hold a C pointer for later use.