From: Mattias EngdegÄrd Date: Sat, 15 Jan 2022 13:51:09 +0000 (+0100) Subject: Bump specpdl inline, move reallocation out of line X-Git-Tag: emacs-29.0.90~2803 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b7902a9b48f8e7f83ab6b90cfd8bc95aab410e6f;p=emacs.git Bump specpdl inline, move reallocation out of line The common case is just to increment `specpdl_ptr`; do that in-line, but move the uncommon reallocation to a separate subroutine. * src/eval.c (grow_specpdl): Now inline, most code moved... (grow_specpdl_allocation): ...here. --- diff --git a/src/eval.c b/src/eval.c index 7c030067327..744fe82347d 100644 --- a/src/eval.c +++ b/src/eval.c @@ -2362,6 +2362,28 @@ alist mapping symbols to their value. */) return unbind_to (count, eval_sub (form)); } +static void +grow_specpdl_allocation (void) +{ + eassert (specpdl_ptr == specpdl + specpdl_size); + + ptrdiff_t count = SPECPDL_INDEX (); + ptrdiff_t max_size = min (max_specpdl_size, PTRDIFF_MAX - 1000); + union specbinding *pdlvec = specpdl - 1; + ptrdiff_t pdlvecsize = specpdl_size + 1; + if (max_size <= specpdl_size) + { + if (max_specpdl_size < 400) + max_size = max_specpdl_size = 400; + if (max_size <= specpdl_size) + xsignal0 (Qexcessive_variable_binding); + } + pdlvec = xpalloc (pdlvec, &pdlvecsize, 1, max_size + 1, sizeof *specpdl); + specpdl = pdlvec + 1; + specpdl_size = pdlvecsize - 1; + specpdl_ptr = specpdl + count; +} + /* Grow the specpdl stack by one entry. The caller should have already initialized the entry. Signal an error on stack overflow. @@ -2372,29 +2394,12 @@ alist mapping symbols to their value. */) never-used entry just before the bottom of the stack; sometimes its address is taken. */ -static void +INLINE void grow_specpdl (void) { specpdl_ptr++; - if (specpdl_ptr == specpdl + specpdl_size) - { - ptrdiff_t count = SPECPDL_INDEX (); - ptrdiff_t max_size = min (max_specpdl_size, PTRDIFF_MAX - 1000); - union specbinding *pdlvec = specpdl - 1; - ptrdiff_t pdlvecsize = specpdl_size + 1; - if (max_size <= specpdl_size) - { - if (max_specpdl_size < 400) - max_size = max_specpdl_size = 400; - if (max_size <= specpdl_size) - xsignal0 (Qexcessive_variable_binding); - } - pdlvec = xpalloc (pdlvec, &pdlvecsize, 1, max_size + 1, sizeof *specpdl); - specpdl = pdlvec + 1; - specpdl_size = pdlvecsize - 1; - specpdl_ptr = specpdl + count; - } + grow_specpdl_allocation (); } ptrdiff_t