summaryrefslogtreecommitdiff
path: root/scope.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2015-12-27 14:07:02 +0000
committerDavid Mitchell <davem@iabyn.com>2016-02-03 09:19:19 +0000
commit3caf0269dd4c609b8c2bc22b54598c642ba63ed8 (patch)
tree15088650105af3273d292e3d54a5ba33b1f91ae3 /scope.c
parent2ef9a108812a6ae3c346882b7338742e392deb89 (diff)
downloadperl-3caf0269dd4c609b8c2bc22b54598c642ba63ed8.tar.gz
offset PL_savestack_max by SS_MAXPUSH
The newer SS_ADD macros expect there to always be SS_MAXPUSH slots free on the savestack; so they can push multiple items, then only check once at the end whether stack needs expanding. This commit makes savestack_grow() set PL_savestack_max to SS_MAXPUSH short of what has actually been allocated. This makes the tests to see whether the stack needs growing slightly simpler, i.e. PL_savestack_ix > PL_savestack_max rather than PL_savestack_ix + SS_MAXPUSH > PL_savestack_max
Diffstat (limited to 'scope.c')
-rw-r--r--scope.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/scope.c b/scope.c
index f1d1ccbe80..78a465bf66 100644
--- a/scope.c
+++ b/scope.c
@@ -140,15 +140,19 @@ Perl_markstack_grow(pTHX)
void
Perl_savestack_grow(pTHX)
{
- PL_savestack_max = GROW(PL_savestack_max) + 4;
- Renew(PL_savestack, PL_savestack_max, ANY);
+ PL_savestack_max = GROW(PL_savestack_max);
+ /* Note that we allocate SS_MAXPUSH slots higher than ss_max
+ * so that SS_ADD_END(), SSGROW() etc can do a simper check */
+ Renew(PL_savestack, PL_savestack_max + SS_MAXPUSH, ANY);
}
void
Perl_savestack_grow_cnt(pTHX_ I32 need)
{
PL_savestack_max = PL_savestack_ix + need;
- Renew(PL_savestack, PL_savestack_max, ANY);
+ /* Note that we allocate SS_MAXPUSH slots higher than ss_max
+ * so that SS_ADD_END(), SSGROW() etc can do a simper check */
+ Renew(PL_savestack, PL_savestack_max + SS_MAXPUSH, ANY);
}
#undef GROW