diff options
| author | Mattias EngdegÄrd | 2022-01-15 14:51:09 +0100 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2022-01-24 11:41:47 +0100 |
| commit | b7902a9b48f8e7f83ab6b90cfd8bc95aab410e6f (patch) | |
| tree | e3aba73bac2d00a1384aeca52cf0199288a9fd3e /src/eval.c | |
| parent | 4a0541a5ddee0485d19dba1960a3a5821cf68fdd (diff) | |
| download | emacs-b7902a9b48f8e7f83ab6b90cfd8bc95aab410e6f.tar.gz emacs-b7902a9b48f8e7f83ab6b90cfd8bc95aab410e6f.zip | |
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.
Diffstat (limited to 'src/eval.c')
| -rw-r--r-- | src/eval.c | 43 |
1 files changed, 24 insertions, 19 deletions
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. */) | |||
| 2362 | return unbind_to (count, eval_sub (form)); | 2362 | return unbind_to (count, eval_sub (form)); |
| 2363 | } | 2363 | } |
| 2364 | 2364 | ||
| 2365 | static void | ||
| 2366 | grow_specpdl_allocation (void) | ||
| 2367 | { | ||
| 2368 | eassert (specpdl_ptr == specpdl + specpdl_size); | ||
| 2369 | |||
| 2370 | ptrdiff_t count = SPECPDL_INDEX (); | ||
| 2371 | ptrdiff_t max_size = min (max_specpdl_size, PTRDIFF_MAX - 1000); | ||
| 2372 | union specbinding *pdlvec = specpdl - 1; | ||
| 2373 | ptrdiff_t pdlvecsize = specpdl_size + 1; | ||
| 2374 | if (max_size <= specpdl_size) | ||
| 2375 | { | ||
| 2376 | if (max_specpdl_size < 400) | ||
| 2377 | max_size = max_specpdl_size = 400; | ||
| 2378 | if (max_size <= specpdl_size) | ||
| 2379 | xsignal0 (Qexcessive_variable_binding); | ||
| 2380 | } | ||
| 2381 | pdlvec = xpalloc (pdlvec, &pdlvecsize, 1, max_size + 1, sizeof *specpdl); | ||
| 2382 | specpdl = pdlvec + 1; | ||
| 2383 | specpdl_size = pdlvecsize - 1; | ||
| 2384 | specpdl_ptr = specpdl + count; | ||
| 2385 | } | ||
| 2386 | |||
| 2365 | /* Grow the specpdl stack by one entry. | 2387 | /* Grow the specpdl stack by one entry. |
| 2366 | The caller should have already initialized the entry. | 2388 | The caller should have already initialized the entry. |
| 2367 | Signal an error on stack overflow. | 2389 | Signal an error on stack overflow. |
| @@ -2372,29 +2394,12 @@ alist mapping symbols to their value. */) | |||
| 2372 | never-used entry just before the bottom of the stack; sometimes its | 2394 | never-used entry just before the bottom of the stack; sometimes its |
| 2373 | address is taken. */ | 2395 | address is taken. */ |
| 2374 | 2396 | ||
| 2375 | static void | 2397 | INLINE void |
| 2376 | grow_specpdl (void) | 2398 | grow_specpdl (void) |
| 2377 | { | 2399 | { |
| 2378 | specpdl_ptr++; | 2400 | specpdl_ptr++; |
| 2379 | |||
| 2380 | if (specpdl_ptr == specpdl + specpdl_size) | 2401 | if (specpdl_ptr == specpdl + specpdl_size) |
| 2381 | { | 2402 | grow_specpdl_allocation (); |
| 2382 | ptrdiff_t count = SPECPDL_INDEX (); | ||
| 2383 | ptrdiff_t max_size = min (max_specpdl_size, PTRDIFF_MAX - 1000); | ||
| 2384 | union specbinding *pdlvec = specpdl - 1; | ||
| 2385 | ptrdiff_t pdlvecsize = specpdl_size + 1; | ||
| 2386 | if (max_size <= specpdl_size) | ||
| 2387 | { | ||
| 2388 | if (max_specpdl_size < 400) | ||
| 2389 | max_size = max_specpdl_size = 400; | ||
| 2390 | if (max_size <= specpdl_size) | ||
| 2391 | xsignal0 (Qexcessive_variable_binding); | ||
| 2392 | } | ||
| 2393 | pdlvec = xpalloc (pdlvec, &pdlvecsize, 1, max_size + 1, sizeof *specpdl); | ||
| 2394 | specpdl = pdlvec + 1; | ||
| 2395 | specpdl_size = pdlvecsize - 1; | ||
| 2396 | specpdl_ptr = specpdl + count; | ||
| 2397 | } | ||
| 2398 | } | 2403 | } |
| 2399 | 2404 | ||
| 2400 | ptrdiff_t | 2405 | ptrdiff_t |