aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorDmitry Antipov2014-09-30 19:35:16 +0400
committerDmitry Antipov2014-09-30 19:35:16 +0400
commit6e28231a10a2c049725942bfcdb71d765822d8d6 (patch)
tree8acf684852b89acf539b21c1f8bfc95b0b1f4a5e /doc
parentc44d4581b74b8281ed365cce750713da8ad4a5fa (diff)
downloademacs-6e28231a10a2c049725942bfcdb71d765822d8d6.tar.gz
emacs-6e28231a10a2c049725942bfcdb71d765822d8d6.zip
* internals.texi (Stack-allocated Objects): Describe this feature.
Diffstat (limited to 'doc')
-rw-r--r--doc/lispref/ChangeLog4
-rw-r--r--doc/lispref/internals.texi26
2 files changed, 30 insertions, 0 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index 1a85b126ffe..36918dac2e4 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,7 @@
12014-09-30 Dmitry Antipov <dmantipov@yandex.ru>
2
3 * internals.texi (Stack-allocated Objects): Describe this feature.
4
12014-09-15 Daniel Colascione <dancol@dancol.org> 52014-09-15 Daniel Colascione <dancol@dancol.org>
2 6
3 * text.texi (Registers): Make `insert-register' documentation 7 * text.texi (Registers): Make `insert-register' documentation
diff --git a/doc/lispref/internals.texi b/doc/lispref/internals.texi
index 3d85b474d4b..1bafd22fd43 100644
--- a/doc/lispref/internals.texi
+++ b/doc/lispref/internals.texi
@@ -14,6 +14,7 @@ internal aspects of GNU Emacs that may be of interest to C programmers.
14* Building Emacs:: How the dumped Emacs is made. 14* Building Emacs:: How the dumped Emacs is made.
15* Pure Storage:: Kludge to make preloaded Lisp functions shareable. 15* Pure Storage:: Kludge to make preloaded Lisp functions shareable.
16* Garbage Collection:: Reclaiming space for Lisp objects no longer used. 16* Garbage Collection:: Reclaiming space for Lisp objects no longer used.
17* Stack-allocated Objects:: Temporary conses and strings on C stack.
17* Memory Usage:: Info about total size of Lisp objects made so far. 18* Memory Usage:: Info about total size of Lisp objects made so far.
18* C Dialect:: What C variant Emacs is written in. 19* C Dialect:: What C variant Emacs is written in.
19* Writing Emacs Primitives:: Writing C code for Emacs. 20* Writing Emacs Primitives:: Writing C code for Emacs.
@@ -529,6 +530,31 @@ during garbage collection so far in this Emacs session, as a
529floating-point number. 530floating-point number.
530@end defvar 531@end defvar
531 532
533@node Stack-allocated Objects
534@section Stack-allocated Objects
535
536@cindex stack allocation overview
537 The garbage collector described above is used to manage data visible
538from Lisp program, as well as the most of data internally used by the
539interpreter. But sometimes it may be useful to allocate temporary
540internal (i.e. not visible for Lisp program) objects using C stack of
541an interpreter. Currently conses and strings are the only objects which
542can be allocated in that way. Strings are limited to ASCII characters
543only and should be treated as immutable (calling @code{ASET} on them is
544undefined).
545
546@cindex stack allocation internals
547 In C, this is implemented as a special macros which expands to
548a @code{Lisp_Object} with block-scoped semantics and lifetime (see
549the code around @code{USE_STACK_LISP_OBJECTS} in @file{lisp.h}). This
550means that these objects are not managed by the garbage collector;
551instead, they are allocated like local variables in C and automatically
552freed when an execution reaches an end of the corresponding scope. Thus,
553allocation and freeing are faster than using garbage collector. But
554remember that passing them out of their scope results in undefined
555behavior. Think twice before using this feature and carefully debug
556your code with @code{GC_CHECK_MARKED_OBJECTS} (see @file{alloc.c}).
557
532@node Memory Usage 558@node Memory Usage
533@section Memory Usage 559@section Memory Usage
534@cindex memory usage 560@cindex memory usage