diff options
| author | Kim F. Storm | 2006-07-13 13:43:50 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2006-07-13 13:43:50 +0000 |
| commit | 8788120ff42d2e5c0be7f2a9856517e7075252ba (patch) | |
| tree | 43a2e12571d96ae3eea0d6d787114168bb6bd30b /src/eval.c | |
| parent | 64de53d81bc8ebdafaafbe377de0a941b53c2e8c (diff) | |
| download | emacs-8788120ff42d2e5c0be7f2a9856517e7075252ba.tar.gz emacs-8788120ff42d2e5c0be7f2a9856517e7075252ba.zip | |
(Fthrow): Remove loop around Fsignal.
(Feval, Fapply, Ffuncall): Optimize for no function indirection.
Use original function name in all signaled errors.
Simplify Fsignal calls (no return).
(funcall_lambda): Simplify Fsignal calls (no return).
Diffstat (limited to 'src/eval.c')
| -rw-r--r-- | src/eval.c | 80 |
1 files changed, 46 insertions, 34 deletions
diff --git a/src/eval.c b/src/eval.c index 30df5f8ea36..a07ab32e76b 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -1289,16 +1289,14 @@ Both TAG and VALUE are evalled. */) | |||
| 1289 | { | 1289 | { |
| 1290 | register struct catchtag *c; | 1290 | register struct catchtag *c; |
| 1291 | 1291 | ||
| 1292 | while (1) | 1292 | if (!NILP (tag)) |
| 1293 | { | 1293 | for (c = catchlist; c; c = c->next) |
| 1294 | if (!NILP (tag)) | 1294 | { |
| 1295 | for (c = catchlist; c; c = c->next) | 1295 | if (EQ (c->tag, tag)) |
| 1296 | { | 1296 | unwind_to_catch (c, value); |
| 1297 | if (EQ (c->tag, tag)) | 1297 | } |
| 1298 | unwind_to_catch (c, value); | 1298 | Fsignal (Qno_catch, list2 (tag, value)); |
| 1299 | } | 1299 | abort (); |
| 1300 | tag = Fsignal (Qno_catch, Fcons (tag, Fcons (value, Qnil))); | ||
| 1301 | } | ||
| 1302 | } | 1300 | } |
| 1303 | 1301 | ||
| 1304 | 1302 | ||
| @@ -2166,7 +2164,12 @@ DEFUN ("eval", Feval, Seval, 1, 1, 0, | |||
| 2166 | /* At this point, only original_fun and original_args | 2164 | /* At this point, only original_fun and original_args |
| 2167 | have values that will be used below */ | 2165 | have values that will be used below */ |
| 2168 | retry: | 2166 | retry: |
| 2169 | fun = Findirect_function (original_fun, Qnil); | 2167 | |
| 2168 | /* Optimize for no indirection. */ | ||
| 2169 | fun = original_fun; | ||
| 2170 | if (SYMBOLP (fun) && !EQ (fun, Qunbound) | ||
| 2171 | && (fun = XSYMBOL (fun)->function, SYMBOLP (fun))) | ||
| 2172 | fun = indirect_function (fun); | ||
| 2170 | 2173 | ||
| 2171 | if (SUBRP (fun)) | 2174 | if (SUBRP (fun)) |
| 2172 | { | 2175 | { |
| @@ -2182,7 +2185,7 @@ DEFUN ("eval", Feval, Seval, 1, 1, 0, | |||
| 2182 | 2185 | ||
| 2183 | if (XINT (numargs) < XSUBR (fun)->min_args || | 2186 | if (XINT (numargs) < XSUBR (fun)->min_args || |
| 2184 | (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args < XINT (numargs))) | 2187 | (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args < XINT (numargs))) |
| 2185 | return Fsignal (Qwrong_number_of_arguments, Fcons (fun, Fcons (numargs, Qnil))); | 2188 | Fsignal (Qwrong_number_of_arguments, list2 (original_fun, numargs)); |
| 2186 | 2189 | ||
| 2187 | if (XSUBR (fun)->max_args == UNEVALLED) | 2190 | if (XSUBR (fun)->max_args == UNEVALLED) |
| 2188 | { | 2191 | { |
| @@ -2285,11 +2288,13 @@ DEFUN ("eval", Feval, Seval, 1, 1, 0, | |||
| 2285 | val = apply_lambda (fun, original_args, 1); | 2288 | val = apply_lambda (fun, original_args, 1); |
| 2286 | else | 2289 | else |
| 2287 | { | 2290 | { |
| 2291 | if (EQ (fun, Qunbound)) | ||
| 2292 | Fsignal (Qvoid_function, Fcons (original_fun, Qnil)); | ||
| 2288 | if (!CONSP (fun)) | 2293 | if (!CONSP (fun)) |
| 2289 | return Fsignal (Qinvalid_function, Fcons (fun, Qnil)); | 2294 | Fsignal (Qinvalid_function, Fcons (original_fun, Qnil)); |
| 2290 | funcar = Fcar (fun); | 2295 | funcar = Fcar (fun); |
| 2291 | if (!SYMBOLP (funcar)) | 2296 | if (!SYMBOLP (funcar)) |
| 2292 | return Fsignal (Qinvalid_function, Fcons (fun, Qnil)); | 2297 | Fsignal (Qinvalid_function, Fcons (original_fun, Qnil)); |
| 2293 | if (EQ (funcar, Qautoload)) | 2298 | if (EQ (funcar, Qautoload)) |
| 2294 | { | 2299 | { |
| 2295 | do_autoload (fun, original_fun); | 2300 | do_autoload (fun, original_fun); |
| @@ -2300,7 +2305,7 @@ DEFUN ("eval", Feval, Seval, 1, 1, 0, | |||
| 2300 | else if (EQ (funcar, Qlambda)) | 2305 | else if (EQ (funcar, Qlambda)) |
| 2301 | val = apply_lambda (fun, original_args, 1); | 2306 | val = apply_lambda (fun, original_args, 1); |
| 2302 | else | 2307 | else |
| 2303 | return Fsignal (Qinvalid_function, Fcons (fun, Qnil)); | 2308 | Fsignal (Qinvalid_function, Fcons (original_fun, Qnil)); |
| 2304 | } | 2309 | } |
| 2305 | done: | 2310 | done: |
| 2306 | CHECK_CONS_LIST (); | 2311 | CHECK_CONS_LIST (); |
| @@ -2345,7 +2350,10 @@ usage: (apply FUNCTION &rest ARGUMENTS) */) | |||
| 2345 | 2350 | ||
| 2346 | numargs += nargs - 2; | 2351 | numargs += nargs - 2; |
| 2347 | 2352 | ||
| 2348 | fun = indirect_function (fun); | 2353 | /* Optimize for no indirection. */ |
| 2354 | if (SYMBOLP (fun) && !EQ (fun, Qunbound) | ||
| 2355 | && (fun = XSYMBOL (fun)->function, SYMBOLP (fun))) | ||
| 2356 | fun = indirect_function (fun); | ||
| 2349 | if (EQ (fun, Qunbound)) | 2357 | if (EQ (fun, Qunbound)) |
| 2350 | { | 2358 | { |
| 2351 | /* Let funcall get the error */ | 2359 | /* Let funcall get the error */ |
| @@ -2824,7 +2832,7 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */) | |||
| 2824 | int nargs; | 2832 | int nargs; |
| 2825 | Lisp_Object *args; | 2833 | Lisp_Object *args; |
| 2826 | { | 2834 | { |
| 2827 | Lisp_Object fun; | 2835 | Lisp_Object fun, original_fun; |
| 2828 | Lisp_Object funcar; | 2836 | Lisp_Object funcar; |
| 2829 | int numargs = nargs - 1; | 2837 | int numargs = nargs - 1; |
| 2830 | Lisp_Object lisp_numargs; | 2838 | Lisp_Object lisp_numargs; |
| @@ -2861,11 +2869,15 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */) | |||
| 2861 | 2869 | ||
| 2862 | CHECK_CONS_LIST (); | 2870 | CHECK_CONS_LIST (); |
| 2863 | 2871 | ||
| 2872 | original_fun = args[0]; | ||
| 2873 | |||
| 2864 | retry: | 2874 | retry: |
| 2865 | 2875 | ||
| 2866 | fun = args[0]; | 2876 | /* Optimize for no indirection. */ |
| 2867 | 2877 | fun = original_fun; | |
| 2868 | fun = Findirect_function (fun, Qnil); | 2878 | if (SYMBOLP (fun) && !EQ (fun, Qunbound) |
| 2879 | && (fun = XSYMBOL (fun)->function, SYMBOLP (fun))) | ||
| 2880 | fun = indirect_function (fun); | ||
| 2869 | 2881 | ||
| 2870 | if (SUBRP (fun)) | 2882 | if (SUBRP (fun)) |
| 2871 | { | 2883 | { |
| @@ -2873,11 +2885,11 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */) | |||
| 2873 | || (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args < numargs)) | 2885 | || (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args < numargs)) |
| 2874 | { | 2886 | { |
| 2875 | XSETFASTINT (lisp_numargs, numargs); | 2887 | XSETFASTINT (lisp_numargs, numargs); |
| 2876 | return Fsignal (Qwrong_number_of_arguments, Fcons (fun, Fcons (lisp_numargs, Qnil))); | 2888 | Fsignal (Qwrong_number_of_arguments, list2 (original_fun, lisp_numargs)); |
| 2877 | } | 2889 | } |
| 2878 | 2890 | ||
| 2879 | if (XSUBR (fun)->max_args == UNEVALLED) | 2891 | if (XSUBR (fun)->max_args == UNEVALLED) |
| 2880 | return Fsignal (Qinvalid_function, Fcons (fun, Qnil)); | 2892 | Fsignal (Qinvalid_function, Fcons (original_fun, Qnil)); |
| 2881 | 2893 | ||
| 2882 | if (XSUBR (fun)->max_args == MANY) | 2894 | if (XSUBR (fun)->max_args == MANY) |
| 2883 | { | 2895 | { |
| @@ -2949,21 +2961,23 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */) | |||
| 2949 | val = funcall_lambda (fun, numargs, args + 1); | 2961 | val = funcall_lambda (fun, numargs, args + 1); |
| 2950 | else | 2962 | else |
| 2951 | { | 2963 | { |
| 2964 | if (EQ (fun, Qunbound)) | ||
| 2965 | Fsignal (Qvoid_function, Fcons (original_fun, Qnil)); | ||
| 2952 | if (!CONSP (fun)) | 2966 | if (!CONSP (fun)) |
| 2953 | return Fsignal (Qinvalid_function, Fcons (fun, Qnil)); | 2967 | Fsignal (Qinvalid_function, Fcons (original_fun, Qnil)); |
| 2954 | funcar = Fcar (fun); | 2968 | funcar = Fcar (fun); |
| 2955 | if (!SYMBOLP (funcar)) | 2969 | if (!SYMBOLP (funcar)) |
| 2956 | return Fsignal (Qinvalid_function, Fcons (fun, Qnil)); | 2970 | Fsignal (Qinvalid_function, Fcons (original_fun, Qnil)); |
| 2957 | if (EQ (funcar, Qlambda)) | 2971 | if (EQ (funcar, Qlambda)) |
| 2958 | val = funcall_lambda (fun, numargs, args + 1); | 2972 | val = funcall_lambda (fun, numargs, args + 1); |
| 2959 | else if (EQ (funcar, Qautoload)) | 2973 | else if (EQ (funcar, Qautoload)) |
| 2960 | { | 2974 | { |
| 2961 | do_autoload (fun, args[0]); | 2975 | do_autoload (fun, original_fun); |
| 2962 | CHECK_CONS_LIST (); | 2976 | CHECK_CONS_LIST (); |
| 2963 | goto retry; | 2977 | goto retry; |
| 2964 | } | 2978 | } |
| 2965 | else | 2979 | else |
| 2966 | return Fsignal (Qinvalid_function, Fcons (fun, Qnil)); | 2980 | Fsignal (Qinvalid_function, Fcons (original_fun, Qnil)); |
| 2967 | } | 2981 | } |
| 2968 | done: | 2982 | done: |
| 2969 | CHECK_CONS_LIST (); | 2983 | CHECK_CONS_LIST (); |
| @@ -3039,7 +3053,7 @@ funcall_lambda (fun, nargs, arg_vector) | |||
| 3039 | if (CONSP (syms_left)) | 3053 | if (CONSP (syms_left)) |
| 3040 | syms_left = XCAR (syms_left); | 3054 | syms_left = XCAR (syms_left); |
| 3041 | else | 3055 | else |
| 3042 | return Fsignal (Qinvalid_function, Fcons (fun, Qnil)); | 3056 | Fsignal (Qinvalid_function, Fcons (fun, Qnil)); |
| 3043 | } | 3057 | } |
| 3044 | else if (COMPILEDP (fun)) | 3058 | else if (COMPILEDP (fun)) |
| 3045 | syms_left = AREF (fun, COMPILED_ARGLIST); | 3059 | syms_left = AREF (fun, COMPILED_ARGLIST); |
| @@ -3052,8 +3066,8 @@ funcall_lambda (fun, nargs, arg_vector) | |||
| 3052 | QUIT; | 3066 | QUIT; |
| 3053 | 3067 | ||
| 3054 | next = XCAR (syms_left); | 3068 | next = XCAR (syms_left); |
| 3055 | while (!SYMBOLP (next)) | 3069 | if (!SYMBOLP (next)) |
| 3056 | next = Fsignal (Qinvalid_function, Fcons (fun, Qnil)); | 3070 | Fsignal (Qinvalid_function, Fcons (fun, Qnil)); |
| 3057 | 3071 | ||
| 3058 | if (EQ (next, Qand_rest)) | 3072 | if (EQ (next, Qand_rest)) |
| 3059 | rest = 1; | 3073 | rest = 1; |
| @@ -3067,17 +3081,15 @@ funcall_lambda (fun, nargs, arg_vector) | |||
| 3067 | else if (i < nargs) | 3081 | else if (i < nargs) |
| 3068 | specbind (next, arg_vector[i++]); | 3082 | specbind (next, arg_vector[i++]); |
| 3069 | else if (!optional) | 3083 | else if (!optional) |
| 3070 | return Fsignal (Qwrong_number_of_arguments, | 3084 | Fsignal (Qwrong_number_of_arguments, list2 (fun, make_number (nargs))); |
| 3071 | Fcons (fun, Fcons (make_number (nargs), Qnil))); | ||
| 3072 | else | 3085 | else |
| 3073 | specbind (next, Qnil); | 3086 | specbind (next, Qnil); |
| 3074 | } | 3087 | } |
| 3075 | 3088 | ||
| 3076 | if (!NILP (syms_left)) | 3089 | if (!NILP (syms_left)) |
| 3077 | return Fsignal (Qinvalid_function, Fcons (fun, Qnil)); | 3090 | Fsignal (Qinvalid_function, Fcons (fun, Qnil)); |
| 3078 | else if (i < nargs) | 3091 | else if (i < nargs) |
| 3079 | return Fsignal (Qwrong_number_of_arguments, | 3092 | Fsignal (Qwrong_number_of_arguments, list2 (fun, make_number (nargs))); |
| 3080 | Fcons (fun, Fcons (make_number (nargs), Qnil))); | ||
| 3081 | 3093 | ||
| 3082 | if (CONSP (fun)) | 3094 | if (CONSP (fun)) |
| 3083 | val = Fprogn (XCDR (XCDR (fun))); | 3095 | val = Fprogn (XCDR (XCDR (fun))); |