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/eval.c | |
parent | 259a643d7f7c56976ff794cbdba8f5c70c795091 (diff) |
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/eval.c')
-rw-r--r-- | src/eval.c | 122 |
1 files changed, 10 insertions, 112 deletions
diff --git a/src/eval.c b/src/eval.c index 9bdcf4bed1..6fde7e30b7 100644 --- a/src/eval.c +++ b/src/eval.c @@ -33,11 +33,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ struct handler *handlerlist; -#ifdef DEBUG_GCPRO -/* Count levels of GCPRO to detect failure to UNGCPRO. */ -int gcpro_level; -#endif - /* Non-nil means record all fset's and provide's, to be undone if the file being autoloaded is not fully loaded. They are recorded by being consed onto the front of Vautoload_queue: @@ -226,7 +221,6 @@ static struct handler handlerlist_sentinel; void init_eval (void) { - gcprolist = 0; byte_stack_list = 0; specpdl_ptr = specpdl; { /* Put a dummy catcher at top-level so that handlerlist is never NULL. @@ -242,9 +236,6 @@ init_eval (void) Vquit_flag = Qnil; debug_on_next_call = 0; lisp_eval_depth = 0; -#ifdef DEBUG_GCPRO - gcpro_level = 0; -#endif /* This is less than the initial value of num_nonmacro_input_events. */ when_entered_debugger = -1; } @@ -344,10 +335,7 @@ If all args return nil, return nil. usage: (or CONDITIONS...) */) (Lisp_Object args) { - register Lisp_Object val = Qnil; - struct gcpro gcpro1; - - GCPRO1 (args); + Lisp_Object val = Qnil; while (CONSP (args)) { @@ -357,7 +345,6 @@ usage: (or CONDITIONS...) */) args = XCDR (args); } - UNGCPRO; return val; } @@ -368,10 +355,7 @@ If no arg yields nil, return the last arg's value. usage: (and CONDITIONS...) */) (Lisp_Object args) { - register Lisp_Object val = Qt; - struct gcpro gcpro1; - - GCPRO1 (args); + Lisp_Object val = Qt; while (CONSP (args)) { @@ -381,7 +365,6 @@ usage: (and CONDITIONS...) */) args = XCDR (args); } - UNGCPRO; return val; } @@ -394,11 +377,8 @@ usage: (if COND THEN ELSE...) */) (Lisp_Object args) { Lisp_Object cond; - struct gcpro gcpro1; - GCPRO1 (args); cond = eval_sub (XCAR (args)); - UNGCPRO; if (!NILP (cond)) return eval_sub (Fcar (XCDR (args))); @@ -418,9 +398,7 @@ usage: (cond CLAUSES...) */) (Lisp_Object args) { Lisp_Object val = args; - struct gcpro gcpro1; - GCPRO1 (args); while (CONSP (args)) { Lisp_Object clause = XCAR (args); @@ -433,7 +411,6 @@ usage: (cond CLAUSES...) */) } args = XCDR (args); } - UNGCPRO; return val; } @@ -444,9 +421,6 @@ usage: (progn BODY...) */) (Lisp_Object body) { Lisp_Object val = Qnil; - struct gcpro gcpro1; - - GCPRO1 (body); while (CONSP (body)) { @@ -454,7 +428,6 @@ usage: (progn BODY...) */) body = XCDR (body); } - UNGCPRO; return val; } @@ -476,17 +449,14 @@ usage: (prog1 FIRST BODY...) */) { Lisp_Object val; Lisp_Object args_left; - struct gcpro gcpro1, gcpro2; args_left = args; val = args; - GCPRO2 (args, val); val = eval_sub (XCAR (args_left)); while (CONSP (args_left = XCDR (args_left))) eval_sub (XCAR (args_left)); - UNGCPRO; return val; } @@ -497,11 +467,7 @@ remaining args, whose values are discarded. usage: (prog2 FORM1 FORM2 BODY...) */) (Lisp_Object args) { - struct gcpro gcpro1; - - GCPRO1 (args); eval_sub (XCAR (args)); - UNGCPRO; return Fprog1 (XCDR (args)); } @@ -522,8 +488,6 @@ usage: (setq [SYM VAL]...) */) if (CONSP (args)) { Lisp_Object args_left = args; - struct gcpro gcpro1; - GCPRO1 (args); do { @@ -543,8 +507,6 @@ usage: (setq [SYM VAL]...) */) args_left = Fcdr (XCDR (args_left)); } while (CONSP (args_left)); - - UNGCPRO; } return val; @@ -854,9 +816,6 @@ usage: (let* VARLIST BODY...) */) { Lisp_Object varlist, var, val, elt, lexenv; ptrdiff_t count = SPECPDL_INDEX (); - struct gcpro gcpro1, gcpro2, gcpro3; - - GCPRO3 (args, elt, varlist); lexenv = Vinternal_interpreter_environment; @@ -900,7 +859,7 @@ usage: (let* VARLIST BODY...) */) varlist = XCDR (varlist); } - UNGCPRO; + val = Fprogn (XCDR (args)); return unbind_to (count, val); } @@ -915,10 +874,9 @@ usage: (let VARLIST BODY...) */) (Lisp_Object args) { Lisp_Object *temps, tem, lexenv; - register Lisp_Object elt, varlist; + Lisp_Object elt, varlist; ptrdiff_t count = SPECPDL_INDEX (); ptrdiff_t argnum; - struct gcpro gcpro1, gcpro2; USE_SAFE_ALLOCA; varlist = XCAR (args); @@ -929,9 +887,6 @@ usage: (let VARLIST BODY...) */) /* Compute the values and store them in `temps'. */ - GCPRO2 (args, *temps); - gcpro2.nvars = 0; - for (argnum = 0; CONSP (varlist); varlist = XCDR (varlist)) { QUIT; @@ -942,9 +897,7 @@ usage: (let VARLIST BODY...) */) signal_error ("`let' bindings can have only one value-form", elt); else temps [argnum++] = eval_sub (Fcar (Fcdr (elt))); - gcpro2.nvars = argnum; } - UNGCPRO; lexenv = Vinternal_interpreter_environment; @@ -984,9 +937,6 @@ usage: (while TEST BODY...) */) (Lisp_Object args) { Lisp_Object test, body; - struct gcpro gcpro1, gcpro2; - - GCPRO2 (test, body); test = XCAR (args); body = XCDR (args); @@ -996,7 +946,6 @@ usage: (while TEST BODY...) */) Fprogn (body); } - UNGCPRO; return Qnil; } @@ -1043,10 +992,7 @@ definitions to shadow the loaded ones for use in file byte-compilation. */) { /* SYM is not mentioned in ENVIRONMENT. Look at its function definition. */ - struct gcpro gcpro1; - GCPRO1 (form); def = Fautoload_do_load (def, sym, Qmacro); - UNGCPRO; if (!CONSP (def)) /* Not defined or definition not suitable. */ break; @@ -1082,12 +1028,7 @@ If a throw happens, it specifies the value to return from `catch'. usage: (catch TAG BODY...) */) (Lisp_Object args) { - register Lisp_Object tag; - struct gcpro gcpro1; - - GCPRO1 (args); - tag = eval_sub (XCAR (args)); - UNGCPRO; + Lisp_Object tag = eval_sub (XCAR (args)); return internal_catch (tag, Fprogn, XCDR (args)); } @@ -1172,10 +1113,6 @@ unwind_to_catch (struct handler *catch, Lisp_Object value) eassert (handlerlist == catch); byte_stack_list = catch->byte_stack; - gcprolist = catch->gcpro; -#ifdef DEBUG_GCPRO - gcpro_level = gcprolist ? gcprolist->level + 1 : 0; -#endif lisp_eval_depth = catch->lisp_eval_depth; sys_longjmp (catch->jmp, 1); @@ -1932,7 +1869,6 @@ it defines a macro. */) (Lisp_Object fundef, Lisp_Object funname, Lisp_Object macro_only) { ptrdiff_t count = SPECPDL_INDEX (); - struct gcpro gcpro1, gcpro2, gcpro3; if (!CONSP (fundef) || !EQ (Qautoload, XCAR (fundef))) return fundef; @@ -1951,7 +1887,6 @@ it defines a macro. */) SDATA (SYMBOL_NAME (funname))); CHECK_SYMBOL (funname); - GCPRO3 (funname, fundef, macro_only); /* Preserve the match data. */ record_unwind_save_match_data (); @@ -1974,8 +1909,6 @@ it defines a macro. */) Vautoload_queue = Qt; unbind_to (count, Qnil); - UNGCPRO; - if (NILP (funname)) return Qnil; else @@ -2063,7 +1996,6 @@ eval_sub (Lisp_Object form) { Lisp_Object fun, val, original_fun, original_args; Lisp_Object funcar; - struct gcpro gcpro1, gcpro2, gcpro3; ptrdiff_t count; if (SYMBOLP (form)) @@ -2086,9 +2018,7 @@ eval_sub (Lisp_Object form) QUIT; - GCPRO1 (form); maybe_gc (); - UNGCPRO; if (++lisp_eval_depth > max_lisp_eval_depth) { @@ -2146,38 +2076,26 @@ eval_sub (Lisp_Object form) SAFE_ALLOCA_LISP (vals, XINT (numargs)); - GCPRO3 (args_left, fun, fun); - gcpro3.var = vals; - gcpro3.nvars = 0; - while (!NILP (args_left)) { vals[argnum++] = eval_sub (Fcar (args_left)); args_left = Fcdr (args_left); - gcpro3.nvars = argnum; } set_backtrace_args (specpdl + count, vals, XINT (numargs)); val = (XSUBR (fun)->function.aMANY) (XINT (numargs), vals); - UNGCPRO; SAFE_FREE (); } else { - GCPRO3 (args_left, fun, fun); - gcpro3.var = argvals; - gcpro3.nvars = 0; - maxargs = XSUBR (fun)->max_args; - for (i = 0; i < maxargs; args_left = Fcdr (args_left)) + for (i = 0; i < maxargs; i++) { argvals[i] = eval_sub (Fcar (args_left)); - gcpro3.nvars = ++i; + args_left = Fcdr (args_left); } - UNGCPRO; - set_backtrace_args (specpdl + count, argvals, XINT (numargs)); switch (i) @@ -2341,7 +2259,6 @@ usage: (apply FUNCTION &rest ARGUMENTS) */) spread_arg = XCDR (spread_arg); } - /* Ffuncall gcpro's all of its args. */ retval = Ffuncall (funcall_nargs, funcall_args); SAFE_FREE (); @@ -2470,16 +2387,13 @@ usage: (run-hook-wrapped HOOK WRAP-FUNCTION &rest ARGS) */) /* ARGS[0] should be a hook symbol. Call each of the functions in the hook value, passing each of them as arguments all the rest of ARGS (all NARGS - 1 elements). - FUNCALL specifies how to call each function on the hook. - The caller (or its caller, etc) must gcpro all of ARGS, - except that it isn't necessary to gcpro ARGS[0]. */ + FUNCALL specifies how to call each function on the hook. */ Lisp_Object run_hook_with_args (ptrdiff_t nargs, Lisp_Object *args, Lisp_Object (*funcall) (ptrdiff_t nargs, Lisp_Object *args)) { Lisp_Object sym, val, ret = Qnil; - struct gcpro gcpro1, gcpro2, gcpro3; /* If we are dying or still initializing, don't do anything--it would probably crash if we tried. */ @@ -2499,7 +2413,6 @@ run_hook_with_args (ptrdiff_t nargs, Lisp_Object *args, else { Lisp_Object global_vals = Qnil; - GCPRO3 (sym, val, global_vals); for (; CONSP (val) && NILP (ret); @@ -2538,7 +2451,6 @@ run_hook_with_args (ptrdiff_t nargs, Lisp_Object *args, } } - UNGCPRO; return ret; } } @@ -2633,8 +2545,6 @@ call7 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3, return CALLN (Ffuncall, fn, arg1, arg2, arg3, arg4, arg5, arg6, arg7); } -/* The caller should GCPRO all the elements of ARGS. */ - DEFUN ("functionp", Ffunctionp, Sfunctionp, 1, 1, 0, doc: /* Non-nil if OBJECT is a function. */) (Lisp_Object object) @@ -2669,10 +2579,8 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */) error ("Lisp nesting exceeds `max-lisp-eval-depth'"); } - /* This also GCPROs them. */ count = record_in_backtrace (args[0], &args[1], nargs - 1); - /* Call GC after setting up the backtrace, so the latter GCPROs the args. */ maybe_gc (); if (debug_on_next_call) @@ -2808,28 +2716,21 @@ apply_lambda (Lisp_Object fun, Lisp_Object args, ptrdiff_t count) Lisp_Object args_left; ptrdiff_t i; EMACS_INT numargs; - register Lisp_Object *arg_vector; - struct gcpro gcpro1, gcpro2, gcpro3; - register Lisp_Object tem; + Lisp_Object *arg_vector; + Lisp_Object tem; USE_SAFE_ALLOCA; numargs = XFASTINT (Flength (args)); SAFE_ALLOCA_LISP (arg_vector, numargs); args_left = args; - GCPRO3 (*arg_vector, args_left, fun); - gcpro1.nvars = 0; - for (i = 0; i < numargs; ) { tem = Fcar (args_left), args_left = Fcdr (args_left); tem = eval_sub (tem); arg_vector[i++] = tem; - gcpro1.nvars = i; } - UNGCPRO; - set_backtrace_args (specpdl + count, arg_vector, i); tem = funcall_lambda (fun, numargs, arg_vector); @@ -3196,9 +3097,7 @@ Lisp_Object unbind_to (ptrdiff_t count, Lisp_Object value) { Lisp_Object quitf = Vquit_flag; - struct gcpro gcpro1, gcpro2; - GCPRO2 (value, quitf); Vquit_flag = Qnil; while (specpdl_ptr != specpdl + count) @@ -3265,7 +3164,6 @@ unbind_to (ptrdiff_t count, Lisp_Object value) if (NILP (Vquit_flag) && !NILP (quitf)) Vquit_flag = quitf; - UNGCPRO; return value; } |