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 /src/lisp.h | |
parent | 259a643d7f7c56976ff794cbdba8f5c70c795091 (diff) | |
download | emacs-60d1b18734fff144f1608da6228d60e4bda7b24c.tar.gz emacs-60d1b18734fff144f1608da6228d60e4bda7b24c.tar.bz2 emacs-60d1b18734fff144f1608da6228d60e4bda7b24c.zip |
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 'src/lisp.h')
-rw-r--r-- | src/lisp.h | 273 |
1 files changed, 1 insertions, 272 deletions
diff --git a/src/lisp.h b/src/lisp.h index bb25ebd9be3..d2d385605ce 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -3031,9 +3031,6 @@ struct handler /* Most global vars are reset to their value via the specpdl mechanism, but a few others are handled by storing their value here. */ -#if true /* GC_MARK_STACK == GC_MAKE_GCPROS_NOOPS, but defined later. */ - struct gcpro *gcpro; -#endif sys_jmp_buf jmp; EMACS_INT lisp_eval_depth; ptrdiff_t pdlcount; @@ -3060,7 +3057,6 @@ struct handler (c)->pdlcount = SPECPDL_INDEX (); \ (c)->poll_suppress_count = poll_suppress_count; \ (c)->interrupt_input_blocked = interrupt_input_blocked;\ - (c)->gcpro = gcprolist; \ (c)->byte_stack = byte_stack_list; \ handlerlist = (c); @@ -3107,262 +3103,6 @@ extern void process_quit_flag (void); extern Lisp_Object Vascii_downcase_table; extern Lisp_Object Vascii_canon_table; -/* Structure for recording stack slots that need marking. */ - -/* This is a chain of structures, each of which points at a Lisp_Object - variable whose value should be marked in garbage collection. - Normally every link of the chain is an automatic variable of a function, - and its `val' points to some argument or local variable of the function. - On exit to the function, the chain is set back to the value it had on entry. - This way, no link remains in the chain when the stack frame containing the - link disappears. - - Every function that can call Feval must protect in this fashion all - Lisp_Object variables whose contents will be used again. */ - -extern struct gcpro *gcprolist; - -struct gcpro -{ - struct gcpro *next; - - /* Address of first protected variable. */ - volatile Lisp_Object *var; - - /* Number of consecutive protected variables. */ - ptrdiff_t nvars; - -#ifdef DEBUG_GCPRO - /* File name where this record is used. */ - const char *name; - - /* Line number in this file. */ - int lineno; - - /* Index in the local chain of records. */ - int idx; - - /* Nesting level. */ - int level; -#endif -}; - -/* Values of GC_MARK_STACK during compilation: - - 0 Use GCPRO as before - 1 Do the real thing, make GCPROs and UNGCPRO no-ops. - 2 Mark the stack, and check that everything GCPRO'd is - marked. - 3 Mark using GCPRO's, mark stack last, and count how many - dead objects are kept alive. - - Formerly, method 0 was used. Currently, method 1 is used unless - otherwise specified by hand when building, e.g., - "make CPPFLAGS='-DGC_MARK_STACK=GC_USE_GCPROS_AS_BEFORE'". - Methods 2 and 3 are present mainly to debug the transition from 0 to 1. */ - -#define GC_USE_GCPROS_AS_BEFORE 0 -#define GC_MAKE_GCPROS_NOOPS 1 -#define GC_MARK_STACK_CHECK_GCPROS 2 -#define GC_USE_GCPROS_CHECK_ZOMBIES 3 - -#ifndef GC_MARK_STACK -#define GC_MARK_STACK GC_MAKE_GCPROS_NOOPS -#endif - -/* Whether we do the stack marking manually. */ -#define BYTE_MARK_STACK !(GC_MARK_STACK == GC_MAKE_GCPROS_NOOPS \ - || GC_MARK_STACK == GC_MARK_STACK_CHECK_GCPROS) - - -#if GC_MARK_STACK == GC_MAKE_GCPROS_NOOPS - -/* Do something silly with gcproN vars just so gcc shuts up. */ -/* You get warnings from MIPSPro... */ - -#define GCPRO1(varname) ((void) gcpro1) -#define GCPRO2(varname1, varname2) ((void) gcpro2, (void) gcpro1) -#define GCPRO3(varname1, varname2, varname3) \ - ((void) gcpro3, (void) gcpro2, (void) gcpro1) -#define GCPRO4(varname1, varname2, varname3, varname4) \ - ((void) gcpro4, (void) gcpro3, (void) gcpro2, (void) gcpro1) -#define GCPRO5(varname1, varname2, varname3, varname4, varname5) \ - ((void) gcpro5, (void) gcpro4, (void) gcpro3, (void) gcpro2, (void) gcpro1) -#define GCPRO6(varname1, varname2, varname3, varname4, varname5, varname6) \ - ((void) gcpro6, (void) gcpro5, (void) gcpro4, (void) gcpro3, (void) gcpro2, \ - (void) gcpro1) -#define GCPRO7(a, b, c, d, e, f, g) (GCPRO6 (a, b, c, d, e, f), (void) gcpro7) -#define UNGCPRO ((void) 0) - -#else /* GC_MARK_STACK != GC_MAKE_GCPROS_NOOPS */ - -#ifndef DEBUG_GCPRO - -#define GCPRO1(a) \ - { gcpro1.next = gcprolist; gcpro1.var = &(a); gcpro1.nvars = 1; \ - gcprolist = &gcpro1; } - -#define GCPRO2(a, b) \ - { gcpro1.next = gcprolist; gcpro1.var = &(a); gcpro1.nvars = 1; \ - gcpro2.next = &gcpro1; gcpro2.var = &(b); gcpro2.nvars = 1; \ - gcprolist = &gcpro2; } - -#define GCPRO3(a, b, c) \ - { gcpro1.next = gcprolist; gcpro1.var = &(a); gcpro1.nvars = 1; \ - gcpro2.next = &gcpro1; gcpro2.var = &(b); gcpro2.nvars = 1; \ - gcpro3.next = &gcpro2; gcpro3.var = &(c); gcpro3.nvars = 1; \ - gcprolist = &gcpro3; } - -#define GCPRO4(a, b, c, d) \ - { gcpro1.next = gcprolist; gcpro1.var = &(a); gcpro1.nvars = 1; \ - gcpro2.next = &gcpro1; gcpro2.var = &(b); gcpro2.nvars = 1; \ - gcpro3.next = &gcpro2; gcpro3.var = &(c); gcpro3.nvars = 1; \ - gcpro4.next = &gcpro3; gcpro4.var = &(d); gcpro4.nvars = 1; \ - gcprolist = &gcpro4; } - -#define GCPRO5(a, b, c, d, e) \ - { gcpro1.next = gcprolist; gcpro1.var = &(a); gcpro1.nvars = 1; \ - gcpro2.next = &gcpro1; gcpro2.var = &(b); gcpro2.nvars = 1; \ - gcpro3.next = &gcpro2; gcpro3.var = &(c); gcpro3.nvars = 1; \ - gcpro4.next = &gcpro3; gcpro4.var = &(d); gcpro4.nvars = 1; \ - gcpro5.next = &gcpro4; gcpro5.var = &(e); gcpro5.nvars = 1; \ - gcprolist = &gcpro5; } - -#define GCPRO6(a, b, c, d, e, f) \ - { gcpro1.next = gcprolist; gcpro1.var = &(a); gcpro1.nvars = 1; \ - gcpro2.next = &gcpro1; gcpro2.var = &(b); gcpro2.nvars = 1; \ - gcpro3.next = &gcpro2; gcpro3.var = &(c); gcpro3.nvars = 1; \ - gcpro4.next = &gcpro3; gcpro4.var = &(d); gcpro4.nvars = 1; \ - gcpro5.next = &gcpro4; gcpro5.var = &(e); gcpro5.nvars = 1; \ - gcpro6.next = &gcpro5; gcpro6.var = &(f); gcpro6.nvars = 1; \ - gcprolist = &gcpro6; } - -#define GCPRO7(a, b, c, d, e, f, g) \ - { gcpro1.next = gcprolist; gcpro1.var = &(a); gcpro1.nvars = 1; \ - gcpro2.next = &gcpro1; gcpro2.var = &(b); gcpro2.nvars = 1; \ - gcpro3.next = &gcpro2; gcpro3.var = &(c); gcpro3.nvars = 1; \ - gcpro4.next = &gcpro3; gcpro4.var = &(d); gcpro4.nvars = 1; \ - gcpro5.next = &gcpro4; gcpro5.var = &(e); gcpro5.nvars = 1; \ - gcpro6.next = &gcpro5; gcpro6.var = &(f); gcpro6.nvars = 1; \ - gcpro7.next = &gcpro6; gcpro7.var = &(g); gcpro7.nvars = 1; \ - gcprolist = &gcpro7; } - -#define UNGCPRO (gcprolist = gcpro1.next) - -#else /* !DEBUG_GCPRO */ - -extern int gcpro_level; - -#define GCPRO1(a) \ - { gcpro1.next = gcprolist; gcpro1.var = &(a); gcpro1.nvars = 1; \ - gcpro1.name = __FILE__; gcpro1.lineno = __LINE__; gcpro1.idx = 1; \ - gcpro1.level = gcpro_level++; \ - gcprolist = &gcpro1; } - -#define GCPRO2(a, b) \ - { gcpro1.next = gcprolist; gcpro1.var = &(a); gcpro1.nvars = 1; \ - gcpro1.name = __FILE__; gcpro1.lineno = __LINE__; gcpro1.idx = 1; \ - gcpro1.level = gcpro_level; \ - gcpro2.next = &gcpro1; gcpro2.var = &(b); gcpro2.nvars = 1; \ - gcpro2.name = __FILE__; gcpro2.lineno = __LINE__; gcpro2.idx = 2; \ - gcpro2.level = gcpro_level++; \ - gcprolist = &gcpro2; } - -#define GCPRO3(a, b, c) \ - { gcpro1.next = gcprolist; gcpro1.var = &(a); gcpro1.nvars = 1; \ - gcpro1.name = __FILE__; gcpro1.lineno = __LINE__; gcpro1.idx = 1; \ - gcpro1.level = gcpro_level; \ - gcpro2.next = &gcpro1; gcpro2.var = &(b); gcpro2.nvars = 1; \ - gcpro2.name = __FILE__; gcpro2.lineno = __LINE__; gcpro2.idx = 2; \ - gcpro3.next = &gcpro2; gcpro3.var = &(c); gcpro3.nvars = 1; \ - gcpro3.name = __FILE__; gcpro3.lineno = __LINE__; gcpro3.idx = 3; \ - gcpro3.level = gcpro_level++; \ - gcprolist = &gcpro3; } - -#define GCPRO4(a, b, c, d) \ - { gcpro1.next = gcprolist; gcpro1.var = &(a); gcpro1.nvars = 1; \ - gcpro1.name = __FILE__; gcpro1.lineno = __LINE__; gcpro1.idx = 1; \ - gcpro1.level = gcpro_level; \ - gcpro2.next = &gcpro1; gcpro2.var = &(b); gcpro2.nvars = 1; \ - gcpro2.name = __FILE__; gcpro2.lineno = __LINE__; gcpro2.idx = 2; \ - gcpro3.next = &gcpro2; gcpro3.var = &(c); gcpro3.nvars = 1; \ - gcpro3.name = __FILE__; gcpro3.lineno = __LINE__; gcpro3.idx = 3; \ - gcpro4.next = &gcpro3; gcpro4.var = &(d); gcpro4.nvars = 1; \ - gcpro4.name = __FILE__; gcpro4.lineno = __LINE__; gcpro4.idx = 4; \ - gcpro4.level = gcpro_level++; \ - gcprolist = &gcpro4; } - -#define GCPRO5(a, b, c, d, e) \ - { gcpro1.next = gcprolist; gcpro1.var = &(a); gcpro1.nvars = 1; \ - gcpro1.name = __FILE__; gcpro1.lineno = __LINE__; gcpro1.idx = 1; \ - gcpro1.level = gcpro_level; \ - gcpro2.next = &gcpro1; gcpro2.var = &(b); gcpro2.nvars = 1; \ - gcpro2.name = __FILE__; gcpro2.lineno = __LINE__; gcpro2.idx = 2; \ - gcpro3.next = &gcpro2; gcpro3.var = &(c); gcpro3.nvars = 1; \ - gcpro3.name = __FILE__; gcpro3.lineno = __LINE__; gcpro3.idx = 3; \ - gcpro4.next = &gcpro3; gcpro4.var = &(d); gcpro4.nvars = 1; \ - gcpro4.name = __FILE__; gcpro4.lineno = __LINE__; gcpro4.idx = 4; \ - gcpro5.next = &gcpro4; gcpro5.var = &(e); gcpro5.nvars = 1; \ - gcpro5.name = __FILE__; gcpro5.lineno = __LINE__; gcpro5.idx = 5; \ - gcpro5.level = gcpro_level++; \ - gcprolist = &gcpro5; } - -#define GCPRO6(a, b, c, d, e, f) \ - { gcpro1.next = gcprolist; gcpro1.var = &(a); gcpro1.nvars = 1; \ - gcpro1.name = __FILE__; gcpro1.lineno = __LINE__; gcpro1.idx = 1; \ - gcpro1.level = gcpro_level; \ - gcpro2.next = &gcpro1; gcpro2.var = &(b); gcpro2.nvars = 1; \ - gcpro2.name = __FILE__; gcpro2.lineno = __LINE__; gcpro2.idx = 2; \ - gcpro3.next = &gcpro2; gcpro3.var = &(c); gcpro3.nvars = 1; \ - gcpro3.name = __FILE__; gcpro3.lineno = __LINE__; gcpro3.idx = 3; \ - gcpro4.next = &gcpro3; gcpro4.var = &(d); gcpro4.nvars = 1; \ - gcpro4.name = __FILE__; gcpro4.lineno = __LINE__; gcpro4.idx = 4; \ - gcpro5.next = &gcpro4; gcpro5.var = &(e); gcpro5.nvars = 1; \ - gcpro5.name = __FILE__; gcpro5.lineno = __LINE__; gcpro5.idx = 5; \ - gcpro6.next = &gcpro5; gcpro6.var = &(f); gcpro6.nvars = 1; \ - gcpro6.name = __FILE__; gcpro6.lineno = __LINE__; gcpro6.idx = 6; \ - gcpro6.level = gcpro_level++; \ - gcprolist = &gcpro6; } - -#define GCPRO7(a, b, c, d, e, f, g) \ - { gcpro1.next = gcprolist; gcpro1.var = &(a); gcpro1.nvars = 1; \ - gcpro1.name = __FILE__; gcpro1.lineno = __LINE__; gcpro1.idx = 1; \ - gcpro1.level = gcpro_level; \ - gcpro2.next = &gcpro1; gcpro2.var = &(b); gcpro2.nvars = 1; \ - gcpro2.name = __FILE__; gcpro2.lineno = __LINE__; gcpro2.idx = 2; \ - gcpro3.next = &gcpro2; gcpro3.var = &(c); gcpro3.nvars = 1; \ - gcpro3.name = __FILE__; gcpro3.lineno = __LINE__; gcpro3.idx = 3; \ - gcpro4.next = &gcpro3; gcpro4.var = &(d); gcpro4.nvars = 1; \ - gcpro4.name = __FILE__; gcpro4.lineno = __LINE__; gcpro4.idx = 4; \ - gcpro5.next = &gcpro4; gcpro5.var = &(e); gcpro5.nvars = 1; \ - gcpro5.name = __FILE__; gcpro5.lineno = __LINE__; gcpro5.idx = 5; \ - gcpro6.next = &gcpro5; gcpro6.var = &(f); gcpro6.nvars = 1; \ - gcpro6.name = __FILE__; gcpro6.lineno = __LINE__; gcpro6.idx = 6; \ - gcpro7.next = &gcpro6; gcpro7.var = &(g); gcpro7.nvars = 1; \ - gcpro7.name = __FILE__; gcpro7.lineno = __LINE__; gcpro7.idx = 7; \ - gcpro7.level = gcpro_level++; \ - gcprolist = &gcpro7; } - -#define UNGCPRO \ - (--gcpro_level != gcpro1.level \ - ? emacs_abort () \ - : (void) (gcprolist = gcpro1.next)) - -#endif /* DEBUG_GCPRO */ -#endif /* GC_MARK_STACK != GC_MAKE_GCPROS_NOOPS */ - - -/* Evaluate expr, UNGCPRO, and then return the value of expr. */ -#define RETURN_UNGCPRO(expr) \ - do \ - { \ - Lisp_Object ret_ungc_val; \ - ret_ungc_val = (expr); \ - UNGCPRO; \ - return ret_ungc_val; \ - } \ - while (false) - /* Call staticpro (&var) to protect static variable `var'. */ void staticpro (Lisp_Object *); @@ -3877,7 +3617,6 @@ extern void init_alloc (void); extern void syms_of_alloc (void); extern struct buffer * allocate_buffer (void); extern int valid_lisp_object_p (Lisp_Object); -extern int relocatable_string_data_p (const char *); #ifdef GC_CHECK_CONS_LIST extern void check_cons_list (void); #else @@ -4320,10 +4059,7 @@ extern int read_bytecode_char (bool); /* Defined in bytecode.c. */ extern void syms_of_bytecode (void); extern struct byte_stack *byte_stack_list; -#if BYTE_MARK_STACK -extern void mark_byte_stack (void); -#endif -extern void unmark_byte_stack (void); +extern void relocate_byte_stack (void); extern Lisp_Object exec_byte_code (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, ptrdiff_t, Lisp_Object *); @@ -4658,13 +4394,6 @@ lisp_word_count (ptrdiff_t nbytes) # define USE_STACK_LISP_OBJECTS true #endif -/* USE_STACK_LISP_OBJECTS requires GC_MARK_STACK == GC_MAKE_GCPROS_NOOPS. */ - -#if GC_MARK_STACK != GC_MAKE_GCPROS_NOOPS -# undef USE_STACK_LISP_OBJECTS -# define USE_STACK_LISP_OBJECTS false -#endif - #ifdef GC_CHECK_STRING_BYTES enum { defined_GC_CHECK_STRING_BYTES = true }; #else |