diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2015-08-26 19:24:28 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2015-08-26 19:24:58 -0700 |
commit | 60d1b18734fff144f1608da6228d60e4bda7b24c (patch) | |
tree | 9b917c91b7de84ba517dba738784e1f1600f9234 /doc/lispref/internals.texi | |
parent | 259a643d7f7c56976ff794cbdba8f5c70c795091 (diff) | |
download | emacs-60d1b18734fff144f1608da6228d60e4bda7b24c.tar.gz |
Assume GC_MARK_STACK == GC_MAKE_GCPROS_NOOPS
This removes the need for GCPRO1 etc. Suggested by Stefan Monnier in:
http://lists.gnu.org/archive/html/emacs-devel/2015-08/msg00918.html
* doc/lispref/internals.texi (Writing Emacs Primitives):
* etc/NEWS:
Document the change.
* src/alloc.c (gcprolist, dump_zombies, MAX_ZOMBIES, zombies)
(nzombies, ngcs, avg_zombies, max_live, max_zombies, avg_live)
(Fgc_status, check_gcpros, relocatable_string_data_p, gc-precise):
* src/bytecode.c (mark_byte_stack) [BYTE_MARK_STACK]:
* src/eval.c (gcpro_level) [DEBUG_GCPRO]:
* src/lisp.h (struct handler.gcpro, struct gcpro, GC_MARK_STACK)
(GC_USE_GCPROS_AS_BEFORE, GC_MAKE_GCPROS_NOOPS)
(GC_MARK_STACK_CHECK_GCPROS, GC_USE_GCPROS_CHECK_ZOMBIES)
(BYTE_MARK_STACK, GCPRO1, GCPRO2, GCPRO3, GCPRO4, GCPRO5, GCPRO6)
(GCPRO7, UNGCPRO, RETURN_UNGCPRO):
Remove. All uses removed. The code now assumes
GC_MARK_STACK == GC_MAKE_GCPROS_NOOPS.
* src/bytecode.c (relocate_byte_stack):
Rename from unmark_byte_stack, since it now only relocates.
All callers changed.
* src/frame.c (make_frame): Add an IF_LINT to pacify GCC 5.2
with GCPROs removed.
* src/systime.h: Use EMACS_LISP_H as the canary instead of GCPRO1.
* test/automated/finalizer-tests.el (finalizer-basic)
(finalizer-circular-reference, finalizer-cross-reference)
(finalizer-error):
* test/automated/generator-tests.el (cps-test-iter-close-finalizer):
Remove tests, as they depend on gc-precise.
Diffstat (limited to 'doc/lispref/internals.texi')
-rw-r--r-- | doc/lispref/internals.texi | 54 |
1 files changed, 13 insertions, 41 deletions
diff --git a/doc/lispref/internals.texi b/doc/lispref/internals.texi index 0b8e28839fc..2a314a596fb 100644 --- a/doc/lispref/internals.texi +++ b/doc/lispref/internals.texi @@ -638,7 +638,6 @@ to read the source, but we can explain some things here. @file{eval.c}. (An ordinary function would have the same general appearance.) -@cindex garbage collection protection @smallexample @group DEFUN ("or", For, Sor, 0, UNEVALLED, 0, @@ -648,15 +647,10 @@ The remaining args are not evalled at all. If all args return nil, return nil. @end group @group -usage: (or CONDITIONS ...) */) +usage: (or CONDITIONS...) */) (Lisp_Object args) @{ - register Lisp_Object val = Qnil; - struct gcpro gcpro1; -@end group - -@group - GCPRO1 (args); + Lisp_Object val = Qnil; @end group @group @@ -670,7 +664,6 @@ usage: (or CONDITIONS ...) */) @end group @group - UNGCPRO; return val; @} @end group @@ -774,36 +767,17 @@ a primitive to accept only a certain type of argument, you must check the type explicitly using a suitable predicate (@pxref{Type Predicates}). @cindex type checking internals -@cindex @code{GCPRO} and @code{UNGCPRO} +@cindex garbage collection protection @cindex protect C variables from garbage collection - Within the function @code{For} itself, note the use of the macros -@code{GCPRO1} and @code{UNGCPRO}. These macros are defined for the -sake of the few platforms which do not use Emacs' default -stack-marking garbage collector. The @code{GCPRO1} macro ``protects'' -a variable from garbage collection, explicitly informing the garbage -collector that that variable and all its contents must be as -accessible. GC protection is necessary in any function which can -perform Lisp evaluation by calling @code{eval_sub} or @code{Feval} as -a subroutine, either directly or indirectly. - - It suffices to ensure that at least one pointer to each object is -GC-protected. Thus, a particular local variable can do without -protection if it is certain that the object it points to will be -preserved by some other pointer (such as another local variable that -has a @code{GCPRO}). Otherwise, the local variable needs a -@code{GCPRO}. - - The macro @code{GCPRO1} protects just one local variable. If you -want to protect two variables, use @code{GCPRO2} instead; repeating -@code{GCPRO1} will not work. Macros @code{GCPRO3}, @code{GCPRO4}, -@code{GCPRO5}, and @code{GCPRO6} also exist. All these macros -implicitly use local variables such as @code{gcpro1}; you must declare -these explicitly, with type @code{struct gcpro}. Thus, if you use -@code{GCPRO2}, you must declare @code{gcpro1} and @code{gcpro2}. - - @code{UNGCPRO} cancels the protection of the variables that are -protected in the current function. It is necessary to do this -explicitly. + Within the function @code{For} itself, the local variable +@code{args} refers to objects controlled by Emacs's stack-marking +garbage collector. Although the garbage collector does not reclaim +objects reachable from C @code{Lisp_Object} stack variables, it may +move non-object components of an object, such as string contents; so +functions that access non-object components must take care to refetch +their addresses after performing Lisp evaluation. Lisp evaluation can +occur via calls to @code{eval_sub} or @code{Feval}, either directly or +indirectly. You must not use C initializers for static or global variables unless the variables are never written once Emacs is dumped. These variables @@ -932,9 +906,7 @@ the Lisp function @code{funcall} accepts an unlimited number of arguments, in C it takes two: the number of Lisp-level arguments, and a one-dimensional array containing their values. The first Lisp-level argument is the Lisp function to call, and the rest are the arguments to -pass to it. Since @code{Ffuncall} can call the evaluator, you must -protect pointers from garbage collection around the call to -@code{Ffuncall}. +pass to it. The C functions @code{call0}, @code{call1}, @code{call2}, and so on, provide handy ways to call a Lisp function conveniently with a fixed |