diff options
| author | Mattias EngdegÄrd | 2022-01-12 12:05:26 +0100 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2022-01-24 11:41:47 +0100 |
| commit | 4a0541a5ddee0485d19dba1960a3a5821cf68fdd (patch) | |
| tree | 4598ac400eb6f65ef279796c9bc830710d96e822 /src | |
| parent | 75c6564c928e6548ec10b938db9693dda3dd09e5 (diff) | |
| download | emacs-4a0541a5ddee0485d19dba1960a3a5821cf68fdd.tar.gz emacs-4a0541a5ddee0485d19dba1960a3a5821cf68fdd.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/eval.c | 44 |
1 files changed, 4 insertions, 40 deletions
diff --git a/src/eval.c b/src/eval.c index 910777e23d5..7c030067327 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -3030,6 +3030,7 @@ Lisp_Object | |||
| 3030 | funcall_general (Lisp_Object fun, ptrdiff_t numargs, Lisp_Object *args) | 3030 | funcall_general (Lisp_Object fun, ptrdiff_t numargs, Lisp_Object *args) |
| 3031 | { | 3031 | { |
| 3032 | Lisp_Object original_fun = fun; | 3032 | Lisp_Object original_fun = fun; |
| 3033 | retry: | ||
| 3033 | if (SYMBOLP (fun) && !NILP (fun) | 3034 | if (SYMBOLP (fun) && !NILP (fun) |
| 3034 | && (fun = XSYMBOL (fun)->u.s.function, SYMBOLP (fun))) | 3035 | && (fun = XSYMBOL (fun)->u.s.function, SYMBOLP (fun))) |
| 3035 | fun = indirect_function (fun); | 3036 | fun = indirect_function (fun); |
| @@ -3055,7 +3056,8 @@ funcall_general (Lisp_Object fun, ptrdiff_t numargs, Lisp_Object *args) | |||
| 3055 | else if (EQ (funcar, Qautoload)) | 3056 | else if (EQ (funcar, Qautoload)) |
| 3056 | { | 3057 | { |
| 3057 | Fautoload_do_load (fun, original_fun, Qnil); | 3058 | Fautoload_do_load (fun, original_fun, Qnil); |
| 3058 | return funcall_general (original_fun, numargs, args); | 3059 | fun = original_fun; |
| 3060 | goto retry; | ||
| 3059 | } | 3061 | } |
| 3060 | else | 3062 | else |
| 3061 | xsignal1 (Qinvalid_function, original_fun); | 3063 | xsignal1 (Qinvalid_function, original_fun); |
| @@ -3069,10 +3071,6 @@ Thus, (funcall \\='cons \\='x \\='y) returns (x . y). | |||
| 3069 | usage: (funcall FUNCTION &rest ARGUMENTS) */) | 3071 | usage: (funcall FUNCTION &rest ARGUMENTS) */) |
| 3070 | (ptrdiff_t nargs, Lisp_Object *args) | 3072 | (ptrdiff_t nargs, Lisp_Object *args) |
| 3071 | { | 3073 | { |
| 3072 | Lisp_Object fun, original_fun; | ||
| 3073 | Lisp_Object funcar; | ||
| 3074 | ptrdiff_t numargs = nargs - 1; | ||
| 3075 | Lisp_Object val; | ||
| 3076 | ptrdiff_t count; | 3074 | ptrdiff_t count; |
| 3077 | 3075 | ||
| 3078 | maybe_quit (); | 3076 | maybe_quit (); |
| @@ -3092,42 +3090,8 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */) | |||
| 3092 | if (debug_on_next_call) | 3090 | if (debug_on_next_call) |
| 3093 | do_debug_on_call (Qlambda, count); | 3091 | do_debug_on_call (Qlambda, count); |
| 3094 | 3092 | ||
| 3095 | original_fun = args[0]; | 3093 | Lisp_Object val = funcall_general (args[0], nargs - 1, args + 1); |
| 3096 | |||
| 3097 | retry: | ||
| 3098 | |||
| 3099 | /* Optimize for no indirection. */ | ||
| 3100 | fun = original_fun; | ||
| 3101 | if (SYMBOLP (fun) && !NILP (fun) | ||
| 3102 | && (fun = XSYMBOL (fun)->u.s.function, SYMBOLP (fun))) | ||
| 3103 | fun = indirect_function (fun); | ||
| 3104 | 3094 | ||
| 3105 | if (SUBRP (fun) && !SUBR_NATIVE_COMPILED_DYNP (fun)) | ||
| 3106 | val = funcall_subr (XSUBR (fun), numargs, args + 1); | ||
| 3107 | else if (COMPILEDP (fun) | ||
| 3108 | || SUBR_NATIVE_COMPILED_DYNP (fun) | ||
| 3109 | || MODULE_FUNCTIONP (fun)) | ||
| 3110 | val = funcall_lambda (fun, numargs, args + 1); | ||
| 3111 | else | ||
| 3112 | { | ||
| 3113 | if (NILP (fun)) | ||
| 3114 | xsignal1 (Qvoid_function, original_fun); | ||
| 3115 | if (!CONSP (fun)) | ||
| 3116 | xsignal1 (Qinvalid_function, original_fun); | ||
| 3117 | funcar = XCAR (fun); | ||
| 3118 | if (!SYMBOLP (funcar)) | ||
| 3119 | xsignal1 (Qinvalid_function, original_fun); | ||
| 3120 | if (EQ (funcar, Qlambda) | ||
| 3121 | || EQ (funcar, Qclosure)) | ||
| 3122 | val = funcall_lambda (fun, numargs, args + 1); | ||
| 3123 | else if (EQ (funcar, Qautoload)) | ||
| 3124 | { | ||
| 3125 | Fautoload_do_load (fun, original_fun, Qnil); | ||
| 3126 | goto retry; | ||
| 3127 | } | ||
| 3128 | else | ||
| 3129 | xsignal1 (Qinvalid_function, original_fun); | ||
| 3130 | } | ||
| 3131 | lisp_eval_depth--; | 3095 | lisp_eval_depth--; |
| 3132 | if (backtrace_debug_on_exit (specpdl + count)) | 3096 | if (backtrace_debug_on_exit (specpdl + count)) |
| 3133 | val = call_debugger (list2 (Qexit, val)); | 3097 | val = call_debugger (list2 (Qexit, val)); |