diff options
| author | Yuan Fu | 2022-10-05 14:22:03 -0700 |
|---|---|---|
| committer | Yuan Fu | 2022-10-05 14:22:03 -0700 |
| commit | 7ebbd4efc3d45403cf845d35c36c21756baeeba8 (patch) | |
| tree | f53223ce7dbd64c079aced6e1a77964d1a8eaa3f /src/eval.c | |
| parent | cb183f6467401fb5ed2b7fc98ca75be9d943cbe3 (diff) | |
| parent | 95efafb72664049f8ac825047df3645656cf76f4 (diff) | |
| download | emacs-7ebbd4efc3d45403cf845d35c36c21756baeeba8.tar.gz emacs-7ebbd4efc3d45403cf845d35c36c21756baeeba8.zip | |
Merge branch 'master' into feature/tree-sitter
Diffstat (limited to 'src/eval.c')
| -rw-r--r-- | src/eval.c | 65 |
1 files changed, 6 insertions, 59 deletions
diff --git a/src/eval.c b/src/eval.c index 6ea7a473f60..de9c07f1552 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -211,15 +211,8 @@ backtrace_thread_next (struct thread_state *tstate, union specbinding *pdl) | |||
| 211 | void | 211 | void |
| 212 | init_eval_once (void) | 212 | init_eval_once (void) |
| 213 | { | 213 | { |
| 214 | /* Don't forget to update docs (lispref node "Local Variables"). */ | 214 | /* Don't forget to update docs (lispref node "Eval"). */ |
| 215 | #ifndef HAVE_NATIVE_COMP | ||
| 216 | max_specpdl_size = 1800; /* See bug#46818. */ | ||
| 217 | max_lisp_eval_depth = 800; | ||
| 218 | #else | ||
| 219 | /* Original values increased for comp.el. */ | ||
| 220 | max_specpdl_size = 2500; | ||
| 221 | max_lisp_eval_depth = 1600; | 215 | max_lisp_eval_depth = 1600; |
| 222 | #endif | ||
| 223 | Vrun_hooks = Qnil; | 216 | Vrun_hooks = Qnil; |
| 224 | pdumper_do_now_and_after_load (init_eval_once_for_pdumper); | 217 | pdumper_do_now_and_after_load (init_eval_once_for_pdumper); |
| 225 | } | 218 | } |
| @@ -270,8 +263,7 @@ max_ensure_room (intmax_t *m, intmax_t a, intmax_t b) | |||
| 270 | static void | 263 | static void |
| 271 | restore_stack_limits (Lisp_Object data) | 264 | restore_stack_limits (Lisp_Object data) |
| 272 | { | 265 | { |
| 273 | integer_to_intmax (XCAR (data), &max_specpdl_size); | 266 | integer_to_intmax (data, &max_lisp_eval_depth); |
| 274 | integer_to_intmax (XCDR (data), &max_lisp_eval_depth); | ||
| 275 | } | 267 | } |
| 276 | 268 | ||
| 277 | /* Call the Lisp debugger, giving it argument ARG. */ | 269 | /* Call the Lisp debugger, giving it argument ARG. */ |
| @@ -283,9 +275,6 @@ call_debugger (Lisp_Object arg) | |||
| 283 | specpdl_ref count = SPECPDL_INDEX (); | 275 | specpdl_ref count = SPECPDL_INDEX (); |
| 284 | Lisp_Object val; | 276 | Lisp_Object val; |
| 285 | intmax_t old_depth = max_lisp_eval_depth; | 277 | intmax_t old_depth = max_lisp_eval_depth; |
| 286 | /* Do not allow max_specpdl_size less than actual depth (Bug#16603). */ | ||
| 287 | ptrdiff_t counti = specpdl_ref_to_count (count); | ||
| 288 | intmax_t old_max = max (max_specpdl_size, counti); | ||
| 289 | 278 | ||
| 290 | /* The previous value of 40 is too small now that the debugger | 279 | /* The previous value of 40 is too small now that the debugger |
| 291 | prints using cl-prin1 instead of prin1. Printing lists nested 8 | 280 | prints using cl-prin1 instead of prin1. Printing lists nested 8 |
| @@ -293,20 +282,8 @@ call_debugger (Lisp_Object arg) | |||
| 293 | currently requires 77 additional frames. See bug#31919. */ | 282 | currently requires 77 additional frames. See bug#31919. */ |
| 294 | max_ensure_room (&max_lisp_eval_depth, lisp_eval_depth, 100); | 283 | max_ensure_room (&max_lisp_eval_depth, lisp_eval_depth, 100); |
| 295 | 284 | ||
| 296 | /* While debugging Bug#16603, previous value of 100 was found | ||
| 297 | too small to avoid specpdl overflow in the debugger itself. */ | ||
| 298 | max_ensure_room (&max_specpdl_size, counti, 200); | ||
| 299 | |||
| 300 | if (old_max == counti) | ||
| 301 | { | ||
| 302 | /* We can enter the debugger due to specpdl overflow (Bug#16603). */ | ||
| 303 | specpdl_ptr--; | ||
| 304 | grow_specpdl (); | ||
| 305 | } | ||
| 306 | |||
| 307 | /* Restore limits after leaving the debugger. */ | 285 | /* Restore limits after leaving the debugger. */ |
| 308 | record_unwind_protect (restore_stack_limits, | 286 | record_unwind_protect (restore_stack_limits, make_int (old_depth)); |
| 309 | Fcons (make_int (old_max), make_int (old_depth))); | ||
| 310 | 287 | ||
| 311 | #ifdef HAVE_WINDOW_SYSTEM | 288 | #ifdef HAVE_WINDOW_SYSTEM |
| 312 | if (display_hourglass_p) | 289 | if (display_hourglass_p) |
| @@ -938,12 +915,9 @@ usage: (let* VARLIST BODY...) */) | |||
| 938 | lexenv = Vinternal_interpreter_environment; | 915 | lexenv = Vinternal_interpreter_environment; |
| 939 | 916 | ||
| 940 | Lisp_Object varlist = XCAR (args); | 917 | Lisp_Object varlist = XCAR (args); |
| 941 | while (CONSP (varlist)) | 918 | FOR_EACH_TAIL (varlist) |
| 942 | { | 919 | { |
| 943 | maybe_quit (); | ||
| 944 | |||
| 945 | elt = XCAR (varlist); | 920 | elt = XCAR (varlist); |
| 946 | varlist = XCDR (varlist); | ||
| 947 | if (SYMBOLP (elt)) | 921 | if (SYMBOLP (elt)) |
| 948 | { | 922 | { |
| 949 | var = elt; | 923 | var = elt; |
| @@ -1757,8 +1731,6 @@ signal_or_quit (Lisp_Object error_symbol, Lisp_Object data, bool keyboard_quit) | |||
| 1757 | { | 1731 | { |
| 1758 | /* Edebug takes care of restoring these variables when it exits. */ | 1732 | /* Edebug takes care of restoring these variables when it exits. */ |
| 1759 | max_ensure_room (&max_lisp_eval_depth, lisp_eval_depth, 20); | 1733 | max_ensure_room (&max_lisp_eval_depth, lisp_eval_depth, 20); |
| 1760 | ptrdiff_t counti = specpdl_ref_to_count (SPECPDL_INDEX ()); | ||
| 1761 | max_ensure_room (&max_specpdl_size, counti, 40); | ||
| 1762 | 1734 | ||
| 1763 | call2 (Vsignal_hook_function, error_symbol, data); | 1735 | call2 (Vsignal_hook_function, error_symbol, data); |
| 1764 | } | 1736 | } |
| @@ -1827,8 +1799,6 @@ signal_or_quit (Lisp_Object error_symbol, Lisp_Object data, bool keyboard_quit) | |||
| 1827 | { | 1799 | { |
| 1828 | max_ensure_room (&max_lisp_eval_depth, lisp_eval_depth, 100); | 1800 | max_ensure_room (&max_lisp_eval_depth, lisp_eval_depth, 100); |
| 1829 | specpdl_ref count = SPECPDL_INDEX (); | 1801 | specpdl_ref count = SPECPDL_INDEX (); |
| 1830 | ptrdiff_t counti = specpdl_ref_to_count (count); | ||
| 1831 | max_ensure_room (&max_specpdl_size, counti, 200); | ||
| 1832 | specbind (Qdebugger, Qdebug_early); | 1802 | specbind (Qdebugger, Qdebug_early); |
| 1833 | call_debugger (list2 (Qerror, Fcons (error_symbol, data))); | 1803 | call_debugger (list2 (Qerror, Fcons (error_symbol, data))); |
| 1834 | unbind_to (count, Qnil); | 1804 | unbind_to (count, Qnil); |
| @@ -1844,12 +1814,10 @@ signal_or_quit (Lisp_Object error_symbol, Lisp_Object data, bool keyboard_quit) | |||
| 1844 | { | 1814 | { |
| 1845 | max_ensure_room (&max_lisp_eval_depth, lisp_eval_depth, 100); | 1815 | max_ensure_room (&max_lisp_eval_depth, lisp_eval_depth, 100); |
| 1846 | specpdl_ref count = SPECPDL_INDEX (); | 1816 | specpdl_ref count = SPECPDL_INDEX (); |
| 1847 | ptrdiff_t counti = specpdl_ref_to_count (count); | ||
| 1848 | AUTO_STRING (redisplay_trace, "*Redisplay_trace*"); | 1817 | AUTO_STRING (redisplay_trace, "*Redisplay_trace*"); |
| 1849 | Lisp_Object redisplay_trace_buffer; | 1818 | Lisp_Object redisplay_trace_buffer; |
| 1850 | AUTO_STRING (gap, "\n\n\n\n"); /* Separates things in *Redisplay-trace* */ | 1819 | AUTO_STRING (gap, "\n\n\n\n"); /* Separates things in *Redisplay-trace* */ |
| 1851 | Lisp_Object delayed_warning; | 1820 | Lisp_Object delayed_warning; |
| 1852 | max_ensure_room (&max_specpdl_size, counti, 200); | ||
| 1853 | redisplay_trace_buffer = Fget_buffer_create (redisplay_trace, Qnil); | 1821 | redisplay_trace_buffer = Fget_buffer_create (redisplay_trace, Qnil); |
| 1854 | current_buffer = XBUFFER (redisplay_trace_buffer); | 1822 | current_buffer = XBUFFER (redisplay_trace_buffer); |
| 1855 | if (!backtrace_yet) /* Are we on the first backtrace of the command? */ | 1823 | if (!backtrace_yet) /* Are we on the first backtrace of the command? */ |
| @@ -2394,17 +2362,12 @@ grow_specpdl_allocation (void) | |||
| 2394 | eassert (specpdl_ptr == specpdl_end); | 2362 | eassert (specpdl_ptr == specpdl_end); |
| 2395 | 2363 | ||
| 2396 | specpdl_ref count = SPECPDL_INDEX (); | 2364 | specpdl_ref count = SPECPDL_INDEX (); |
| 2397 | ptrdiff_t max_size = min (max_specpdl_size, PTRDIFF_MAX - 1000); | 2365 | ptrdiff_t max_size = PTRDIFF_MAX - 1000; |
| 2398 | union specbinding *pdlvec = specpdl - 1; | 2366 | union specbinding *pdlvec = specpdl - 1; |
| 2399 | ptrdiff_t size = specpdl_end - specpdl; | 2367 | ptrdiff_t size = specpdl_end - specpdl; |
| 2400 | ptrdiff_t pdlvecsize = size + 1; | 2368 | ptrdiff_t pdlvecsize = size + 1; |
| 2401 | if (max_size <= size) | 2369 | if (max_size <= size) |
| 2402 | { | 2370 | xsignal0 (Qexcessive_variable_binding); /* Can't happen, essentially. */ |
| 2403 | if (max_specpdl_size < 400) | ||
| 2404 | max_size = max_specpdl_size = 400; | ||
| 2405 | if (max_size <= size) | ||
| 2406 | xsignal0 (Qexcessive_variable_binding); | ||
| 2407 | } | ||
| 2408 | pdlvec = xpalloc (pdlvec, &pdlvecsize, 1, max_size + 1, sizeof *specpdl); | 2371 | pdlvec = xpalloc (pdlvec, &pdlvecsize, 1, max_size + 1, sizeof *specpdl); |
| 2409 | specpdl = pdlvec + 1; | 2372 | specpdl = pdlvec + 1; |
| 2410 | specpdl_end = specpdl + pdlvecsize - 1; | 2373 | specpdl_end = specpdl + pdlvecsize - 1; |
| @@ -4247,22 +4210,6 @@ Lisp_Object backtrace_top_function (void) | |||
| 4247 | void | 4210 | void |
| 4248 | syms_of_eval (void) | 4211 | syms_of_eval (void) |
| 4249 | { | 4212 | { |
| 4250 | DEFVAR_INT ("max-specpdl-size", max_specpdl_size, | ||
| 4251 | doc: /* Limit on number of Lisp variable bindings and `unwind-protect's. | ||
| 4252 | |||
| 4253 | If Lisp code tries to use more bindings than this amount, an error is | ||
| 4254 | signaled. | ||
| 4255 | |||
| 4256 | You can safely increase this variable substantially if the default | ||
| 4257 | value proves inconveniently small. However, if you increase it too | ||
| 4258 | much, Emacs could run out of memory trying to make the stack bigger. | ||
| 4259 | Note that this limit may be silently increased by the debugger if | ||
| 4260 | `debug-on-error' or `debug-on-quit' is set. | ||
| 4261 | |||
| 4262 | \"spec\" is short for \"special variables\", i.e., dynamically bound | ||
| 4263 | variables. \"PDL\" is short for \"push-down list\", which is an old | ||
| 4264 | term for \"stack\". */); | ||
| 4265 | |||
| 4266 | DEFVAR_INT ("max-lisp-eval-depth", max_lisp_eval_depth, | 4213 | DEFVAR_INT ("max-lisp-eval-depth", max_lisp_eval_depth, |
| 4267 | doc: /* Limit on depth in `eval', `apply' and `funcall' before error. | 4214 | doc: /* Limit on depth in `eval', `apply' and `funcall' before error. |
| 4268 | 4215 | ||