diff options
| author | Dmitry Antipov | 2012-11-08 18:10:28 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2012-11-08 18:10:28 +0400 |
| commit | 914adc427f7d1159356e465ec616c65a2ea902af (patch) | |
| tree | a4af121088abea87624dd93640d1deb1dd54ea95 /src/buffer.h | |
| parent | d14bb752ea51331ce2fb459c6ffacd8b11f80bb0 (diff) | |
| download | emacs-914adc427f7d1159356e465ec616c65a2ea902af.tar.gz emacs-914adc427f7d1159356e465ec616c65a2ea902af.zip | |
Shrink struct vectorlike_header to the only size field.
* lisp.h (enum pvec_type): Avoid explicit enum member values.
Adjust comment.
(enum More_Lisp_Bits): Change PSEUDOVECTOR_SIZE_BITS and
PVEC_TYPE_MASK to arrange new bitfield in the vector header.
(PSEUDOVECTOR_REST_BITS, PSEUDOVECTOR_REST_MASK): New members.
(PSEUDOVECTOR_AREA_BITS): New member used to extract subtype
information from the vector header. Adjust comment.
(XSETPVECTYPE, XSETPVECTYPESIZE, XSETTYPED_PSEUDOVECTOR)
(PSEUDOVECTOR_TYPEP, DEFUN): Adjust to match new vector header
layout.
(XSETSUBR, SUBRP): Adjust to match new Lisp_Subr layout.
(struct vectorlike_header): Remove next member. Adjust comment.
(struct Lisp_Subr): Add convenient header. Adjust comment.
(allocate_pseudovector): Adjust prototype.
* alloc.c (mark_glyph_matrix, mark_face_cache, allocate_string)
(sweep_string, lisp_malloc): Remove useless prototypes.
(enum mem_type): Adjust comment.
(NEXT_IN_FREE_LIST): New macro.
(SETUP_ON_FREE_LIST): Adjust XSETPVECTYPESIZE usage.
(Fmake_bool_vector): Likewise.
(struct large_vector): New type to represent allocation unit for
the vectors with the memory footprint more than VBLOOCK_BYTES_MAX.
(large_vectors): Change type to struct large_vector.
(allocate_vector_from_block): Simplify.
(PSEUDOVECTOR_NBYTES): Replace with...
(vector_nbytes): ...new function. Adjust users.
(sweep_vectors): Adjust processing of large vectors.
(allocate_vectorlike): Likewise.
(allocate_pseudovector): Change type of 3rd arg to enum pvec_type.
Add easserts. Adjust XSETPVECTYPESIZE usage.
(allocate_buffer): Use BUFFER_PVEC_INIT.
(live_vector_p): Adjust to match large vector.
* buffer.c (init_buffer_once): Use BUFFER_PVEC_INIT.
* buffer.h (struct buffer): Add next member.
(BUFFER_LISP_SIZE, BUFFER_REST_SIZE, BUFFER_PVEC_INIT):
New macros.
(FOR_EACH_BUFFER): Adjust to match struct buffer change.
* fns.c (internal_equal): Adjust to match enum pvec_type change.
(copy_hash_table): Adjust to match vector header change.
* lread.c (defsubr): Use XSETPVECTYPE.
* .gdbinit (xpr, xbacktrace): Adjust to match vector header change.
(xvectype): Likewise. Print PVEC_NORMAL_VECTOR for regular vectors.
(xvecsize): New command.
Diffstat (limited to 'src/buffer.h')
| -rw-r--r-- | src/buffer.h | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/src/buffer.h b/src/buffer.h index 9e0e9eef0b1..fbbbf1b8434 100644 --- a/src/buffer.h +++ b/src/buffer.h | |||
| @@ -482,11 +482,6 @@ struct buffer_text | |||
| 482 | 482 | ||
| 483 | struct buffer | 483 | struct buffer |
| 484 | { | 484 | { |
| 485 | /* HEADER.NEXT is the next buffer, in chain of all buffers, including killed | ||
| 486 | buffers. This chain, starting from all_buffers, is used only for garbage | ||
| 487 | collection, in order to collect killed buffers properly. Note that large | ||
| 488 | vectors and large pseudo-vector objects are all on another chain starting | ||
| 489 | from large_vectors. */ | ||
| 490 | struct vectorlike_header header; | 485 | struct vectorlike_header header; |
| 491 | 486 | ||
| 492 | /* The name of this buffer. */ | 487 | /* The name of this buffer. */ |
| @@ -750,6 +745,9 @@ struct buffer | |||
| 750 | In an indirect buffer, this is the own_text field of another buffer. */ | 745 | In an indirect buffer, this is the own_text field of another buffer. */ |
| 751 | struct buffer_text *text; | 746 | struct buffer_text *text; |
| 752 | 747 | ||
| 748 | /* Next buffer, in chain of all buffers, including killed ones. */ | ||
| 749 | struct buffer *next; | ||
| 750 | |||
| 753 | /* Char position of point in buffer. */ | 751 | /* Char position of point in buffer. */ |
| 754 | ptrdiff_t pt; | 752 | ptrdiff_t pt; |
| 755 | 753 | ||
| @@ -959,6 +957,27 @@ bset_width_table (struct buffer *b, Lisp_Object val) | |||
| 959 | b->INTERNAL_FIELD (width_table) = val; | 957 | b->INTERNAL_FIELD (width_table) = val; |
| 960 | } | 958 | } |
| 961 | 959 | ||
| 960 | /* Number of Lisp_Objects at the beginning of struct buffer. | ||
| 961 | If you add, remove, or reorder Lisp_Objects within buffer | ||
| 962 | structure, make sure that this is still correct. */ | ||
| 963 | |||
| 964 | #define BUFFER_LISP_SIZE \ | ||
| 965 | ((offsetof (struct buffer, own_text) - header_size) / word_size) | ||
| 966 | |||
| 967 | /* Size of the struct buffer part beyond leading Lisp_Objects, in word_size | ||
| 968 | units. Rounding is needed for --with-wide-int configuration. */ | ||
| 969 | |||
| 970 | #define BUFFER_REST_SIZE \ | ||
| 971 | ((((sizeof (struct buffer) - offsetof (struct buffer, own_text)) \ | ||
| 972 | + (word_size - 1)) & ~(word_size - 1)) / word_size) | ||
| 973 | |||
| 974 | /* Initialize the pseudovector header of buffer object. BUFFER_LISP_SIZE | ||
| 975 | is required for GC, but BUFFER_REST_SIZE is set up just to be consistent | ||
| 976 | with other pseudovectors. */ | ||
| 977 | |||
| 978 | #define BUFFER_PVEC_INIT(b) \ | ||
| 979 | XSETPVECTYPESIZE (b, PVEC_BUFFER, BUFFER_LISP_SIZE, BUFFER_REST_SIZE) | ||
| 980 | |||
| 962 | /* Convenient check whether buffer B is live. */ | 981 | /* Convenient check whether buffer B is live. */ |
| 963 | 982 | ||
| 964 | #define BUFFER_LIVE_P(b) (!NILP (BVAR (b, name))) | 983 | #define BUFFER_LIVE_P(b) (!NILP (BVAR (b, name))) |
| @@ -986,7 +1005,7 @@ extern struct buffer *all_buffers; | |||
| 986 | /* Used to iterate over the chain above. */ | 1005 | /* Used to iterate over the chain above. */ |
| 987 | 1006 | ||
| 988 | #define FOR_EACH_BUFFER(b) \ | 1007 | #define FOR_EACH_BUFFER(b) \ |
| 989 | for ((b) = all_buffers; (b); (b) = (b)->header.next.buffer) | 1008 | for ((b) = all_buffers; (b); (b) = (b)->next) |
| 990 | 1009 | ||
| 991 | /* This points to the current buffer. */ | 1010 | /* This points to the current buffer. */ |
| 992 | 1011 | ||