emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

scratch/bytecode-speedup 273d220f5d 1/3: Bump specpdl inline, move reall


From: Mattias Engdegård
Subject: scratch/bytecode-speedup 273d220f5d 1/3: Bump specpdl inline, move reallocation out of line
Date: Thu, 20 Jan 2022 16:25:07 -0500 (EST)

branch: scratch/bytecode-speedup
commit 273d220f5da1b2abd12ff2d5b2b07661bff995b4
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>

    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.
---
 src/eval.c | 45 +++++++++++++++++++++++++--------------------
 1 file changed, 25 insertions(+), 20 deletions(-)

diff --git a/src/eval.c b/src/eval.c
index 6469f11866..5bba222841 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -2362,6 +2362,29 @@ 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)
+       signal_error ("Variable binding depth exceeds max-specpdl-size",
+                     Qnil);
+    }
+  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,30 +2395,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)
-           signal_error ("Variable binding depth exceeds max-specpdl-size",
-                         Qnil);
-       }
-      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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]