aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorDmitry Antipov2012-06-08 12:44:30 +0400
committerDmitry Antipov2012-06-08 12:44:30 +0400
commitf3372c8789c843a00912e7fc9793ded4beb9a35a (patch)
tree72217e83c99d83ce8b56884b0a21276669e1699b /doc
parentd52ba5afda376fedc679ac6d4e003867d70866dd (diff)
downloademacs-f3372c8789c843a00912e7fc9793ded4beb9a35a.tar.gz
emacs-f3372c8789c843a00912e7fc9793ded4beb9a35a.zip
Block-based vector allocation of small vectors.
* src/lisp.h (struct vectorlike_header): New field `nbytes', adjust comment accordingly. * src/alloc.c (enum mem_type): New type `MEM_TYPE_VECTOR_BLOCK' to denote vector blocks. Adjust users (live_vector_p, mark_maybe_pointer, valid_lisp_object_p) accordingly. (COMMON_MULTIPLE): Move outside #if USE_LSB_TAG. (VECTOR_BLOCK_SIZE, vroundup, VECTOR_BLOCK_BYTES), (VBLOCK_BYTES_MIN, VBLOCK_BYTES_MAX, VECTOR_MAX_FREE_LIST_INDEX), (VECTOR_FREE_LIST_FLAG, ADVANCE, VINDEX, SETUP_ON_FREE_LIST), (VECTOR_SIZE, VECTOR_IN_BLOCK): New macros. (roundup_size): New constant. (struct vector_block): New data type. (vector_blocks, vector_free_lists, zero_vector): New variables. (all_vectors): Renamed to `large_vectors'. (allocate_vector_from_block, init_vectors, allocate_vector_from_block) (sweep_vectors): New functions. (allocate_vectorlike): Return `zero_vector' as the only vector of 0 items. Allocate new vector from block if vector size is less than or equal to VBLOCK_BYTES_MAX. (Fgarbage_collect): Move all vector sweeping code to sweep_vectors. (init_alloc_once): Add call to init_vectors. * doc/lispref/internals.text (Garbage Collection): Document new vector management code and vectorlike_header structure.
Diffstat (limited to 'doc')
-rw-r--r--doc/lispref/ChangeLog5
-rw-r--r--doc/lispref/internals.texi29
2 files changed, 28 insertions, 6 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index b774809feb9..1ef5595fa06 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,8 @@
12012-06-08 Dmitry Antipov <dmantipov@yandex.ru>
2
3 * internals.text (Garbage Collection): Document new
4 vector management code and vectorlike_header structure.
5
12012-06-03 Chong Yidong <cyd@gnu.org> 62012-06-03 Chong Yidong <cyd@gnu.org>
2 7
3 * modes.texi (Mode Line Data): Use "mode line construct" 8 * modes.texi (Mode Line Data): Use "mode line construct"
diff --git a/doc/lispref/internals.texi b/doc/lispref/internals.texi
index 5d4a9c6a3af..1d0a7102a22 100644
--- a/doc/lispref/internals.texi
+++ b/doc/lispref/internals.texi
@@ -215,10 +215,23 @@ You should not change this flag in a running Emacs.
215(such as by loading a library), that data is placed in normal storage. 215(such as by loading a library), that data is placed in normal storage.
216If normal storage runs low, then Emacs asks the operating system to 216If normal storage runs low, then Emacs asks the operating system to
217allocate more memory. Different types of Lisp objects, such as 217allocate more memory. Different types of Lisp objects, such as
218symbols, cons cells, markers, etc., are segregated in distinct blocks 218symbols, cons cells, small vectors, markers, etc., are segregated in
219in memory. (Vectors, long strings, buffers and certain other editing 219distinct blocks in memory. (Large vectors, long strings, buffers and
220types, which are fairly large, are allocated in individual blocks, one 220certain other editing types, which are fairly large, are allocated in
221per object, while small strings are packed into blocks of 8k bytes.) 221individual blocks, one per object; small strings are packed into blocks
222of 8k bytes, and small vectors are packed into blocks of 4k bytes).
223
224@cindex vector-like objects, storage
225@cindex storage of vector-like Lisp objects
226 Beyond the basic vector, a lot of objects like window, buffer, and
227frame are managed as if they were vectors. The corresponding C data
228structures include the @code{struct vectorlike_header} field whose
229@code{next} field points to the next object in the chain:
230@code{header.next.buffer} points to the next buffer (which could be
231a killed buffer), and @code{header.next.vector} points to the next
232vector in a free list. If a vector is small (smaller than or equal to
233@code{VBLOCK_BYTES_MIN} bytes, see @file{alloc.c}), then
234@code{header.next.nbytes} contains the vector size in bytes.
222 235
223@cindex garbage collection 236@cindex garbage collection
224 It is quite common to use some storage for a while, then release it 237 It is quite common to use some storage for a while, then release it
@@ -243,8 +256,12 @@ might as well be reused, since no one will miss them. The second
243 The sweep phase puts unused cons cells onto a @dfn{free list} 256 The sweep phase puts unused cons cells onto a @dfn{free list}
244for future allocation; likewise for symbols and markers. It compacts 257for future allocation; likewise for symbols and markers. It compacts
245the accessible strings so they occupy fewer 8k blocks; then it frees the 258the accessible strings so they occupy fewer 8k blocks; then it frees the
246other 8k blocks. Vectors, buffers, windows, and other large objects are 259other 8k blocks. Unreachable vectors from vector blocks are coalesced
247individually allocated and freed using @code{malloc} and @code{free}. 260to create largest possible free areas; if a free area spans a complete
2614k block, that block is freed. Otherwise, the free area is recorded
262in a free list array, where each entry corresponds to a free list
263of areas of the same size. Large vectors, buffers, and other large
264objects are allocated and freed individually.
248 265
249@cindex CL note---allocate more storage 266@cindex CL note---allocate more storage
250@quotation 267@quotation