[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 4a0541a5dd 12/14: Implement Ffuncall in terms of funcall_general
From: |
Mattias Engdegård |
Subject: |
master 4a0541a5dd 12/14: Implement Ffuncall in terms of funcall_general |
Date: |
Mon, 24 Jan 2022 05:42:37 -0500 (EST) |
branch: master
commit 4a0541a5ddee0485d19dba1960a3a5821cf68fdd
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>
Implement Ffuncall in terms of funcall_general
* src/eval.c (funcall_general, Ffuncall): Delegate the actual work in
Ffuncall to funcall_general which does exactly this.
This slows down some less used function call paths by a small amount
but the code duplication was just silly.
---
src/eval.c | 44 ++++----------------------------------------
1 file changed, 4 insertions(+), 40 deletions(-)
diff --git a/src/eval.c b/src/eval.c
index 910777e23d..7c03006732 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -3030,6 +3030,7 @@ Lisp_Object
funcall_general (Lisp_Object fun, ptrdiff_t numargs, Lisp_Object *args)
{
Lisp_Object original_fun = fun;
+ retry:
if (SYMBOLP (fun) && !NILP (fun)
&& (fun = XSYMBOL (fun)->u.s.function, SYMBOLP (fun)))
fun = indirect_function (fun);
@@ -3055,7 +3056,8 @@ funcall_general (Lisp_Object fun, ptrdiff_t numargs,
Lisp_Object *args)
else if (EQ (funcar, Qautoload))
{
Fautoload_do_load (fun, original_fun, Qnil);
- return funcall_general (original_fun, numargs, args);
+ fun = original_fun;
+ goto retry;
}
else
xsignal1 (Qinvalid_function, original_fun);
@@ -3069,10 +3071,6 @@ Thus, (funcall \\='cons \\='x \\='y) returns (x . y).
usage: (funcall FUNCTION &rest ARGUMENTS) */)
(ptrdiff_t nargs, Lisp_Object *args)
{
- Lisp_Object fun, original_fun;
- Lisp_Object funcar;
- ptrdiff_t numargs = nargs - 1;
- Lisp_Object val;
ptrdiff_t count;
maybe_quit ();
@@ -3092,42 +3090,8 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */)
if (debug_on_next_call)
do_debug_on_call (Qlambda, count);
- original_fun = args[0];
-
- retry:
-
- /* Optimize for no indirection. */
- fun = original_fun;
- if (SYMBOLP (fun) && !NILP (fun)
- && (fun = XSYMBOL (fun)->u.s.function, SYMBOLP (fun)))
- fun = indirect_function (fun);
+ Lisp_Object val = funcall_general (args[0], nargs - 1, args + 1);
- if (SUBRP (fun) && !SUBR_NATIVE_COMPILED_DYNP (fun))
- val = funcall_subr (XSUBR (fun), numargs, args + 1);
- else if (COMPILEDP (fun)
- || SUBR_NATIVE_COMPILED_DYNP (fun)
- || MODULE_FUNCTIONP (fun))
- val = funcall_lambda (fun, numargs, args + 1);
- else
- {
- if (NILP (fun))
- xsignal1 (Qvoid_function, original_fun);
- if (!CONSP (fun))
- xsignal1 (Qinvalid_function, original_fun);
- funcar = XCAR (fun);
- if (!SYMBOLP (funcar))
- xsignal1 (Qinvalid_function, original_fun);
- if (EQ (funcar, Qlambda)
- || EQ (funcar, Qclosure))
- val = funcall_lambda (fun, numargs, args + 1);
- else if (EQ (funcar, Qautoload))
- {
- Fautoload_do_load (fun, original_fun, Qnil);
- goto retry;
- }
- else
- xsignal1 (Qinvalid_function, original_fun);
- }
lisp_eval_depth--;
if (backtrace_debug_on_exit (specpdl + count))
val = call_debugger (list2 (Qexit, val));
- master updated (bcf844b5fc -> a8b713d83a), Mattias Engdegård, 2022/01/24
- master 15961108c9 01/14: Short-circuit the recursive bytecode funcall chain, Mattias Engdegård, 2022/01/24
- master ce1de3a8d9 03/14: Inline setcar and setcdr in byte-code interpreter, Mattias Engdegård, 2022/01/24
- master 6c000af611 02/14: Inline fixnum operations in bytecode interpreter, Mattias Engdegård, 2022/01/24
- master 65caf5b205 04/14: Pin bytecode strings to avoid copy at call time, Mattias Engdegård, 2022/01/24
- master 7392f2dc41 05/14: Byte code arity check micro-optimisation, Mattias Engdegård, 2022/01/24
- master 4a0541a5dd 12/14: Implement Ffuncall in terms of funcall_general,
Mattias Engdegård <=
- master b3377e67a7 07/14: Remove nil check in exec_byte_code, Mattias Engdegård, 2022/01/24
- master 4ff1fb8eb4 08/14: Move a runtime interpreter check to debug mode, Mattias Engdegård, 2022/01/24
- master 11e1abd5cc 10/14: Open-code aref and aset in bytecode interpreter, Mattias Engdegård, 2022/01/24
- master 721357b868 09/14: Remove the unused unbind-all bytecode, Mattias Engdegård, 2022/01/24
- master d05f387407 06/14: ; * src/bytecode.c (exec_byte_code): Cosmetic improvement, Mattias Engdegård, 2022/01/24
- master 75c6564c92 11/14: ; * lisp/emacs-lisp/byte-opt.el: Remove outdated comments, Mattias Engdegård, 2022/01/24
- master b7902a9b48 13/14: Bump specpdl inline, move reallocation out of line, Mattias Engdegård, 2022/01/24
- master a8b713d83a 14/14: Inline maybe_quit, Mattias Engdegård, 2022/01/24
- Re: master updated (bcf844b5fc -> a8b713d83a), Lars Ingebrigtsen, 2022/01/24