From d79cdcd4ff6687c2f0dcfde83ba36732408e52e8 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Fri, 28 Oct 2022 11:33:24 -0400 Subject: cconv.el: Fix regression in cconv-tests-interactive-closure-bug51695 The new code to make interpreted closures safe-for-space introduced a regression in `cconv-tests-interactive-closure-bug51695`, only seen when using TEST_LOAD_EL. A few other issues were found and fixed along the way. * lisp/emacs-lisp/cconv.el (cconv-fv): Change calling convention and focus on finding the free variables. (cconv-make-interpreted-closure): New function. * lisp/loadup.el: Use `compiled-function-p` rather than `byte-code-function-p` so we also use safe-for-space interpreted closures when we build with native compilation. (internal-make-interpreted-closure-function): Use `cconv-make-interpreted-closure`. * src/eval.c (syms_of_eval): Rename `internal-filter-closure-env-function` to `internal-make-interpreted-closure-function`. (Ffunction): Let that new var build the actual closure. * test/lisp/emacs-lisp/cconv-tests.el (cconv-tests-interactive-closure-bug51695): Test specifically the interpreted case. --- src/eval.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/eval.c b/src/eval.c index d2cab006d11..2928a45ac1e 100644 --- a/src/eval.c +++ b/src/eval.c @@ -550,15 +550,12 @@ usage: (function ARG) */) CHECK_STRING (docstring); cdr = Fcons (XCAR (cdr), Fcons (docstring, XCDR (XCDR (cdr)))); } - Lisp_Object env - = NILP (Vinternal_filter_closure_env_function) - ? Vinternal_interpreter_environment - /* FIXME: This macroexpands the body, so we should use the resulting - macroexpanded code! */ - : call2 (Vinternal_filter_closure_env_function, - Fcons (Qprogn, CONSP (cdr) ? XCDR (cdr) : cdr), - Vinternal_interpreter_environment); - return Fcons (Qclosure, Fcons (env, cdr)); + if (NILP (Vinternal_make_interpreted_closure_function)) + return Fcons (Qclosure, Fcons (Vinternal_interpreter_environment, cdr)); + else + return call2 (Vinternal_make_interpreted_closure_function, + Fcons (Qlambda, cdr), + Vinternal_interpreter_environment); } else /* Simply quote the argument. */ @@ -4361,10 +4358,10 @@ alist of active lexical bindings. */); (Just imagine if someone makes it buffer-local). */ Funintern (Qinternal_interpreter_environment, Qnil); - DEFVAR_LISP ("internal-filter-closure-env-function", - Vinternal_filter_closure_env_function, + DEFVAR_LISP ("internal-make-interpreted-closure-function", + Vinternal_make_interpreted_closure_function, doc: /* Function to filter the env when constructing a closure. */); - Vinternal_filter_closure_env_function = Qnil; + Vinternal_make_interpreted_closure_function = Qnil; Vrun_hooks = intern_c_string ("run-hooks"); staticpro (&Vrun_hooks); -- cgit v1.2.1