summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--malloc.c3
-rw-r--r--perl.c35
-rw-r--r--scope.c22
3 files changed, 42 insertions, 18 deletions
diff --git a/malloc.c b/malloc.c
index 6f8f548f1e..0e1745844a 100644
--- a/malloc.c
+++ b/malloc.c
@@ -618,6 +618,9 @@ realloc(void *mp, size_t nbytes)
* FIRST_BIG_TWO_POT, but the new one is near the lower end.
*/
if (was_alloced &&
+#ifdef STRESS_REALLOC
+ 0 && /* always do it the hard way */
+#endif
nbytes <= onb && (nbytes > ( (onb >> 1) - M_OVERHEAD )
#ifdef TWO_POT_OPTIMIZE
|| (i == (FIRST_BIG_TWO_POT - 3)
diff --git a/perl.c b/perl.c
index 47830530cb..00fd96a4e3 100644
--- a/perl.c
+++ b/perl.c
@@ -2403,26 +2403,33 @@ init_debugger(void)
curstash = defstash;
}
+#ifndef STRESS_REALLOC
+#define REASONABLE(size) (size)
+#else
+#define REASONABLE(size) (1) /* unreasonable */
+#endif
+
void
init_stacks(ARGSproto)
{
curstack = newAV();
mainstack = curstack; /* remember in case we switch stacks */
AvREAL_off(curstack); /* not a real array */
- av_extend(curstack,127);
+ av_extend(curstack,REASONABLE(127));
stack_base = AvARRAY(curstack);
stack_sp = stack_base;
- stack_max = stack_base + 127;
+ stack_max = stack_base + REASONABLE(127);
- cxstack_max = 8192 / sizeof(PERL_CONTEXT) - 2; /* Use most of 8K. */
+ /* Use most of 8K. */
+ cxstack_max = REASONABLE(8192 / sizeof(PERL_CONTEXT) - 2);
New(50,cxstack,cxstack_max + 1,PERL_CONTEXT);
cxstack_ix = -1;
- New(50,tmps_stack,128,SV*);
+ New(50,tmps_stack,REASONABLE(128),SV*);
tmps_floor = -1;
tmps_ix = -1;
- tmps_max = 128;
+ tmps_max = REASONABLE(128);
/*
* The following stacks almost certainly should be per-interpreter,
@@ -2432,36 +2439,38 @@ init_stacks(ARGSproto)
if (markstack) {
markstack_ptr = markstack;
} else {
- New(54,markstack,64,I32);
+ New(54,markstack,REASONABLE(32),I32);
markstack_ptr = markstack;
- markstack_max = markstack + 64;
+ markstack_max = markstack + REASONABLE(32);
}
if (scopestack) {
scopestack_ix = 0;
} else {
- New(54,scopestack,32,I32);
+ New(54,scopestack,REASONABLE(32),I32);
scopestack_ix = 0;
- scopestack_max = 32;
+ scopestack_max = REASONABLE(32);
}
if (savestack) {
savestack_ix = 0;
} else {
- New(54,savestack,128,ANY);
+ New(54,savestack,REASONABLE(128),ANY);
savestack_ix = 0;
- savestack_max = 128;
+ savestack_max = REASONABLE(128);
}
if (retstack) {
retstack_ix = 0;
} else {
- New(54,retstack,16,OP*);
+ New(54,retstack,REASONABLE(16),OP*);
retstack_ix = 0;
- retstack_max = 16;
+ retstack_max = REASONABLE(16);
}
}
+#undef REASONABLE
+
static void
nuke_stacks(void)
{
diff --git a/scope.c b/scope.c
index 73aadff141..6de1841eb5 100644
--- a/scope.c
+++ b/scope.c
@@ -25,18 +25,28 @@ stack_grow(SV **sp, SV **p, int n)
abort();
#endif
stack_sp = sp;
+#ifndef STRESS_REALLOC
av_extend(curstack, (p - stack_base) + (n) + 128);
+#else
+ av_extend(curstack, (p - stack_base) + (n) + 1);
+#endif
#if defined(DEBUGGING) && !defined(USE_THREADS)
growing--;
#endif
return stack_sp;
}
+#ifndef STRESS_REALLOC
+#define GROW(old) ((old) * 3 / 2)
+#else
+#define GROW(old) ((old) + 1)
+#endif
+
I32
cxinc(void)
{
dTHR;
- cxstack_max = cxstack_max * 3 / 2;
+ cxstack_max = GROW(cxstack_max);
Renew(cxstack, cxstack_max + 1, PERL_CONTEXT); /* XXX should fix CXINC macro */
return cxstack_ix + 1;
}
@@ -46,7 +56,7 @@ push_return(OP *retop)
{
dTHR;
if (retstack_ix == retstack_max) {
- retstack_max = retstack_max * 3 / 2;
+ retstack_max = GROW(retstack_max);
Renew(retstack, retstack_max, OP*);
}
retstack[retstack_ix++] = retop;
@@ -67,7 +77,7 @@ push_scope(void)
{
dTHR;
if (scopestack_ix == scopestack_max) {
- scopestack_max = scopestack_max * 3 / 2;
+ scopestack_max = GROW(scopestack_max);
Renew(scopestack, scopestack_max, I32);
}
scopestack[scopestack_ix++] = savestack_ix;
@@ -87,7 +97,7 @@ markstack_grow(void)
{
dTHR;
I32 oldmax = markstack_max - markstack;
- I32 newmax = oldmax * 3 / 2;
+ I32 newmax = GROW(oldmax);
Renew(markstack, newmax, I32);
markstack_ptr = markstack + oldmax;
@@ -98,10 +108,12 @@ void
savestack_grow(void)
{
dTHR;
- savestack_max = savestack_max * 3 / 2;
+ savestack_max = GROW(savestack_max) + 4;
Renew(savestack, savestack_max, ANY);
}
+#undef GROW
+
void
free_tmps(void)
{