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,
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)
{
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;
}
{
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;
{
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;
{
dTHR;
I32 oldmax = markstack_max - markstack;
- I32 newmax = oldmax * 3 / 2;
+ I32 newmax = GROW(oldmax);
Renew(markstack, newmax, I32);
markstack_ptr = markstack + oldmax;
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)
{