Commit d7a7fda3 authored by Dmitry Antipov's avatar Dmitry Antipov
Browse files

Cleanup miscellaneous objects allocation and initialization.

* alloc.c (allocate_misc): Change to static.  Add argument to
specify the subtype.  Adjust comment and users.
(build_overlay): New function.
* buffer.c (copy_overlays, Fmake_overlay): Use it.
* lisp.h (struct Lisp_Overlay): Remove obsolete comment.
(allocate_misc): Remove prototype.
(build_overlay): Add prototype.
parent 5df16078
2012-07-22 Dmitry Antipov <dmantipov@yandex.ru> 2012-07-23 Dmitry Antipov <dmantipov@yandex.ru>
Cleanup miscellaneous objects allocation and initialization.
* alloc.c (allocate_misc): Change to static. Add argument to
specify the subtype. Adjust comment and users.
(build_overlay): New function.
* buffer.c (copy_overlays, Fmake_overlay): Use it.
* lisp.h (struct Lisp_Overlay): Remove obsolete comment.
(allocate_misc): Remove prototype.
(build_overlay): Add prototype.
2012-07-23 Dmitry Antipov <dmantipov@yandex.ru>
   
Swap buffer text indirection counters in Fbuffer_swap_text. Swap buffer text indirection counters in Fbuffer_swap_text.
* buffer.c (Fbuffer_swap_text): Swap indirections too. * buffer.c (Fbuffer_swap_text): Swap indirections too.
......
...@@ -3564,10 +3564,10 @@ static int marker_block_index = MARKER_BLOCK_SIZE; ...@@ -3564,10 +3564,10 @@ static int marker_block_index = MARKER_BLOCK_SIZE;
static union Lisp_Misc *marker_free_list; static union Lisp_Misc *marker_free_list;
/* Return a newly allocated Lisp_Misc object, with no substructure. */ /* Return a newly allocated Lisp_Misc object of specified TYPE. */
Lisp_Object static Lisp_Object
allocate_misc (void) allocate_misc (enum Lisp_Misc_Type type)
{ {
Lisp_Object val; Lisp_Object val;
...@@ -3599,6 +3599,7 @@ allocate_misc (void) ...@@ -3599,6 +3599,7 @@ allocate_misc (void)
--total_free_markers; --total_free_markers;
consing_since_gc += sizeof (union Lisp_Misc); consing_since_gc += sizeof (union Lisp_Misc);
misc_objects_consed++; misc_objects_consed++;
XMISCTYPE (val) = type;
XMISCANY (val)->gcmarkbit = 0; XMISCANY (val)->gcmarkbit = 0;
return val; return val;
} }
...@@ -3625,8 +3626,7 @@ make_save_value (void *pointer, ptrdiff_t integer) ...@@ -3625,8 +3626,7 @@ make_save_value (void *pointer, ptrdiff_t integer)
register Lisp_Object val; register Lisp_Object val;
register struct Lisp_Save_Value *p; register struct Lisp_Save_Value *p;
val = allocate_misc (); val = allocate_misc (Lisp_Misc_Save_Value);
XMISCTYPE (val) = Lisp_Misc_Save_Value;
p = XSAVE_VALUE (val); p = XSAVE_VALUE (val);
p->pointer = pointer; p->pointer = pointer;
p->integer = integer; p->integer = integer;
...@@ -3634,6 +3634,21 @@ make_save_value (void *pointer, ptrdiff_t integer) ...@@ -3634,6 +3634,21 @@ make_save_value (void *pointer, ptrdiff_t integer)
return val; return val;
} }
/* Return a Lisp_Misc_Overlay object with specified START, END and PLIST. */
Lisp_Object
build_overlay (Lisp_Object start, Lisp_Object end, Lisp_Object plist)
{
register Lisp_Object overlay;
overlay = allocate_misc (Lisp_Misc_Overlay);
OVERLAY_START (overlay) = start;
OVERLAY_END (overlay) = end;
OVERLAY_PLIST (overlay) = plist;
XOVERLAY (overlay)->next = NULL;
return overlay;
}
DEFUN ("make-marker", Fmake_marker, Smake_marker, 0, 0, 0, DEFUN ("make-marker", Fmake_marker, Smake_marker, 0, 0, 0,
doc: /* Return a newly allocated marker which does not point at any place. */) doc: /* Return a newly allocated marker which does not point at any place. */)
(void) (void)
...@@ -3641,8 +3656,7 @@ DEFUN ("make-marker", Fmake_marker, Smake_marker, 0, 0, 0, ...@@ -3641,8 +3656,7 @@ DEFUN ("make-marker", Fmake_marker, Smake_marker, 0, 0, 0,
register Lisp_Object val; register Lisp_Object val;
register struct Lisp_Marker *p; register struct Lisp_Marker *p;
val = allocate_misc (); val = allocate_misc (Lisp_Misc_Marker);
XMISCTYPE (val) = Lisp_Misc_Marker;
p = XMARKER (val); p = XMARKER (val);
p->buffer = 0; p->buffer = 0;
p->bytepos = 0; p->bytepos = 0;
...@@ -3667,8 +3681,7 @@ build_marker (struct buffer *buf, ptrdiff_t charpos, ptrdiff_t bytepos) ...@@ -3667,8 +3681,7 @@ build_marker (struct buffer *buf, ptrdiff_t charpos, ptrdiff_t bytepos)
/* Every character is at least one byte. */ /* Every character is at least one byte. */
eassert (charpos <= bytepos); eassert (charpos <= bytepos);
obj = allocate_misc (); obj = allocate_misc (Lisp_Misc_Marker);
XMISCTYPE (obj) = Lisp_Misc_Marker;
m = XMARKER (obj); m = XMARKER (obj);
m->buffer = buf; m->buffer = buf;
m->charpos = charpos; m->charpos = charpos;
......
...@@ -433,12 +433,8 @@ copy_overlays (struct buffer *b, struct Lisp_Overlay *list) ...@@ -433,12 +433,8 @@ copy_overlays (struct buffer *b, struct Lisp_Overlay *list)
XMARKER (end)->insertion_type XMARKER (end)->insertion_type
= XMARKER (OVERLAY_END (old_overlay))->insertion_type; = XMARKER (OVERLAY_END (old_overlay))->insertion_type;
overlay = allocate_misc (); overlay = build_overlay
XMISCTYPE (overlay) = Lisp_Misc_Overlay; (start, end, Fcopy_sequence (OVERLAY_PLIST (old_overlay)));
OVERLAY_START (overlay) = start;
OVERLAY_END (overlay) = end;
OVERLAY_PLIST (overlay) = Fcopy_sequence (OVERLAY_PLIST (old_overlay));
XOVERLAY (overlay)->next = NULL;
if (tail) if (tail)
tail = tail->next = XOVERLAY (overlay); tail = tail->next = XOVERLAY (overlay);
...@@ -3640,12 +3636,7 @@ for the rear of the overlay advance when text is inserted there ...@@ -3640,12 +3636,7 @@ for the rear of the overlay advance when text is inserted there
if (!NILP (rear_advance)) if (!NILP (rear_advance))
XMARKER (end)->insertion_type = 1; XMARKER (end)->insertion_type = 1;
overlay = allocate_misc (); overlay = build_overlay (beg, end, Qnil);
XMISCTYPE (overlay) = Lisp_Misc_Overlay;
XOVERLAY (overlay)->start = beg;
XOVERLAY (overlay)->end = end;
XOVERLAY (overlay)->plist = Qnil;
XOVERLAY (overlay)->next = NULL;
/* Put the new overlay on the wrong list. */ /* Put the new overlay on the wrong list. */
end = OVERLAY_END (overlay); end = OVERLAY_END (overlay);
......
...@@ -1286,16 +1286,6 @@ struct Lisp_Marker ...@@ -1286,16 +1286,6 @@ struct Lisp_Marker
/* START and END are markers in the overlay's buffer, and /* START and END are markers in the overlay's buffer, and
PLIST is the overlay's property list. */ PLIST is the overlay's property list. */
struct Lisp_Overlay struct Lisp_Overlay
/* An overlay's real data content is:
- plist
- buffer
- insertion type of both ends
- start & start_byte
- end & end_byte
- next (singly linked list of overlays).
- start_next and end_next (singly linked list of markers).
I.e. 9words plus 2 bits, 3words of which are for external linked lists.
*/
{ {
ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_Overlay */ ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_Overlay */
unsigned gcmarkbit : 1; unsigned gcmarkbit : 1;
...@@ -2605,7 +2595,6 @@ extern Lisp_Object list3 (Lisp_Object, Lisp_Object, Lisp_Object); ...@@ -2605,7 +2595,6 @@ extern Lisp_Object list3 (Lisp_Object, Lisp_Object, Lisp_Object);
extern Lisp_Object list4 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object); extern Lisp_Object list4 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object);
extern Lisp_Object list5 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, extern Lisp_Object list5 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object,
Lisp_Object); Lisp_Object);
extern Lisp_Object allocate_misc (void);
extern _Noreturn void string_overflow (void); extern _Noreturn void string_overflow (void);
extern Lisp_Object make_string (const char *, ptrdiff_t); extern Lisp_Object make_string (const char *, ptrdiff_t);
extern Lisp_Object make_formatted_string (char *, const char *, ...) extern Lisp_Object make_formatted_string (char *, const char *, ...)
...@@ -2667,6 +2656,7 @@ extern Lisp_Object make_float (double); ...@@ -2667,6 +2656,7 @@ extern Lisp_Object make_float (double);
extern void display_malloc_warning (void); extern void display_malloc_warning (void);
extern ptrdiff_t inhibit_garbage_collection (void); extern ptrdiff_t inhibit_garbage_collection (void);
extern Lisp_Object make_save_value (void *, ptrdiff_t); extern Lisp_Object make_save_value (void *, ptrdiff_t);
extern Lisp_Object build_overlay (Lisp_Object, Lisp_Object, Lisp_Object);
extern void free_marker (Lisp_Object); extern void free_marker (Lisp_Object);
extern void free_cons (struct Lisp_Cons *); extern void free_cons (struct Lisp_Cons *);
extern void init_alloc_once (void); extern void init_alloc_once (void);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment