Branch: refs/heads/yves/unify_SSCHECK_and_SSGROW
  Home:   https://github.com/Perl/perl5
  Commit: 81d9b321946a5fdd8db818f5c8d138728d21423c
      
https://github.com/Perl/perl5/commit/81d9b321946a5fdd8db818f5c8d138728d21423c
  Author: Yves Orton <[email protected]>
  Date:   2023-02-19 (Sun, 19 Feb 2023)

  Changed paths:
    M regexec.c
    M scope.c
    M scope.h

  Log Message:
  -----------
  scope.c - rework SSGROW() and SSCHECK() macros and undelying functions

Prior to this patch SSCHECK() took a "needs" parameter, but did not
actually guarantee that the stack would be sufficiently large to
accomodate that many elements after the call. This was quite misleading.
Especially as SSGROW() would not do geometric preallocation, but
SSCHECK() would, so much of the time SSCHECK() would appear to be a
better choice, but not always.

This patch makes it so SSCHECK() is an alias for SSGROW(), and it makes
it so that SSGROW() also geometrically overallocates. The underlying
function that used to implement SSCHECK() savestack_grow() now calls the
savestack_grow_cnt() which has always implemented SSGROW(). Anything
in the internals that used to call SSCHECK() now calls SSGROW() instead.

At the same time the preallocation has been made a little bit more
aggressive, ensuring that we always allocate at least SS_MAXPUSH
elements on top of what was requested as part of the "known" size of the
stack, and additional SS_MAXPUSH elements which are not part of the
"known" size of the stack. This "hidden extra" is used to simply some of
the other macros which are used a lot internally. (I have beefed up the
comment explaining this as well.)

See https://github.com/Perl/perl5/pull/20530 where Dave M points out the
problem with this logic. Currently I don't think we have a good way to
test for the error that he showed so unfortunately this patch lacks a
test.


Reply via email to