aboutsummaryrefslogtreecommitdiffstats
path: root/src/eval.c
diff options
context:
space:
mode:
authorMattias EngdegÄrd2022-02-26 12:49:02 +0100
committerMattias EngdegÄrd2022-03-12 17:32:31 +0100
commitfe65db05f42bcbf755f037575b3c29b74f279bdf (patch)
treec184bf57ac6a9bc7489c9c7700dcc3bd4441083d /src/eval.c
parent213483124b4381663efd0dd001037363223ce188 (diff)
downloademacs-fe65db05f42bcbf755f037575b3c29b74f279bdf.tar.gz
emacs-fe65db05f42bcbf755f037575b3c29b74f279bdf.zip
Maintain end of specpdl instead of size
Keep track of the end of specpdl explicitly since that is what we are comparing against on critical code paths. * src/eval.c (init_eval_once_for_pdumper, signal_or_quit) (grow_specpdl_allocation): * src/fileio.c (Fdo_auto_save): * src/lisp.h (grow_specpdl): * src/thread.c (run_thread, Fmake_thread): * src/thread.h (struct thread_state): Replace specpdl_size with specpdl_end, according to the equation specpdl_end = specpdl + specpdl_size.
Diffstat (limited to 'src/eval.c')
-rw-r--r--src/eval.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/eval.c b/src/eval.c
index 0fc492fbe0e..a9d56ca23b3 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -223,8 +223,8 @@ init_eval_once_for_pdumper (void)
223{ 223{
224 enum { size = 50 }; 224 enum { size = 50 };
225 union specbinding *pdlvec = malloc ((size + 1) * sizeof *specpdl); 225 union specbinding *pdlvec = malloc ((size + 1) * sizeof *specpdl);
226 specpdl_size = size;
227 specpdl = specpdl_ptr = pdlvec + 1; 226 specpdl = specpdl_ptr = pdlvec + 1;
227 specpdl_end = specpdl + size;
228} 228}
229 229
230void 230void
@@ -1773,7 +1773,7 @@ signal_or_quit (Lisp_Object error_symbol, Lisp_Object data, bool keyboard_quit)
1773 && ! NILP (error_symbol) 1773 && ! NILP (error_symbol)
1774 /* Don't try to call a lisp function if we've already overflowed 1774 /* Don't try to call a lisp function if we've already overflowed
1775 the specpdl stack. */ 1775 the specpdl stack. */
1776 && specpdl_ptr < specpdl + specpdl_size) 1776 && specpdl_ptr < specpdl_end)
1777 { 1777 {
1778 /* Edebug takes care of restoring these variables when it exits. */ 1778 /* Edebug takes care of restoring these variables when it exits. */
1779 max_ensure_room (&max_lisp_eval_depth, lisp_eval_depth, 20); 1779 max_ensure_room (&max_lisp_eval_depth, lisp_eval_depth, 20);
@@ -2323,22 +2323,23 @@ alist mapping symbols to their value. */)
2323void 2323void
2324grow_specpdl_allocation (void) 2324grow_specpdl_allocation (void)
2325{ 2325{
2326 eassert (specpdl_ptr == specpdl + specpdl_size); 2326 eassert (specpdl_ptr == specpdl_end);
2327 2327
2328 specpdl_ref count = SPECPDL_INDEX (); 2328 specpdl_ref count = SPECPDL_INDEX ();
2329 ptrdiff_t max_size = min (max_specpdl_size, PTRDIFF_MAX - 1000); 2329 ptrdiff_t max_size = min (max_specpdl_size, PTRDIFF_MAX - 1000);
2330 union specbinding *pdlvec = specpdl - 1; 2330 union specbinding *pdlvec = specpdl - 1;
2331 ptrdiff_t pdlvecsize = specpdl_size + 1; 2331 ptrdiff_t size = specpdl_end - specpdl;
2332 if (max_size <= specpdl_size) 2332 ptrdiff_t pdlvecsize = size + 1;
2333 if (max_size <= size)
2333 { 2334 {
2334 if (max_specpdl_size < 400) 2335 if (max_specpdl_size < 400)
2335 max_size = max_specpdl_size = 400; 2336 max_size = max_specpdl_size = 400;
2336 if (max_size <= specpdl_size) 2337 if (max_size <= size)
2337 xsignal0 (Qexcessive_variable_binding); 2338 xsignal0 (Qexcessive_variable_binding);
2338 } 2339 }
2339 pdlvec = xpalloc (pdlvec, &pdlvecsize, 1, max_size + 1, sizeof *specpdl); 2340 pdlvec = xpalloc (pdlvec, &pdlvecsize, 1, max_size + 1, sizeof *specpdl);
2340 specpdl = pdlvec + 1; 2341 specpdl = pdlvec + 1;
2341 specpdl_size = pdlvecsize - 1; 2342 specpdl_end = specpdl + pdlvecsize - 1;
2342 specpdl_ptr = specpdl_ref_to_ptr (count); 2343 specpdl_ptr = specpdl_ref_to_ptr (count);
2343} 2344}
2344 2345