summaryrefslogtreecommitdiff
path: root/perl.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 /perl.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 'perl.c')
-rw-r--r--perl.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/perl.c b/perl.c
index 1160e3226a..55afb6ac06 100644
--- a/perl.c
+++ b/perl.c
@@ -4078,6 +4078,8 @@ Perl_init_debugger(pTHX)
void
Perl_init_stacks(pTHX)
{
+ SSize_t size;
+
/* start with 128-item stack and 8K cxstack */
PL_curstackinfo = new_stackinfo(REASONABLE(128),
REASONABLE(8192/sizeof(PERL_CONTEXT) - 1));
@@ -4107,9 +4109,11 @@ Perl_init_stacks(pTHX)
PL_scopestack_ix = 0;
PL_scopestack_max = REASONABLE(32);
- Newx(PL_savestack,REASONABLE_but_at_least(128,SS_MAXPUSH),ANY);
+ size = REASONABLE_but_at_least(128,SS_MAXPUSH);
+ Newx(PL_savestack, size, ANY);
PL_savestack_ix = 0;
- PL_savestack_max = REASONABLE_but_at_least(128,SS_MAXPUSH);
+ /*PL_savestack_max lies: it always has SS_MAXPUSH more than it claims */
+ PL_savestack_max = size - SS_MAXPUSH;
}
#undef REASONABLE