Check if function is naked before adding +1 for PROC opcide (#357)

This commit is contained in:
Adrian Graber 2018-09-02 19:40:35 +02:00 committed by Barnaby Keene
parent 01d27f88e8
commit 6dec728efe
2 changed files with 14 additions and 5 deletions

View File

@ -2337,8 +2337,13 @@ static int declloc(int fstatic)
modstk(-(int)size*sizeof(cell));
assert(curfunc!=NULL);
assert((curfunc->usage & uNATIVE)==0);
if (curfunc->x.stacksize<declared+1)
curfunc->x.stacksize=declared+1; /* +1 for PROC opcode */
if (curfunc->flags & flagNAKED) {
if (curfunc->x.stacksize<declared)
curfunc->x.stacksize=declared;
} else {
if (curfunc->x.stacksize<declared+1)
curfunc->x.stacksize=declared+1; /* +1 for PROC opcode */
} /* if */
} /* if */
/* now that we have reserved memory for the variable, we can proceed
* to initialize it */
@ -3156,7 +3161,10 @@ SC_FUNC symbol *fetchfunc(char *name,int tag)
/* set library ID to NULL (only for native functions) */
sym->x.lib=NULL;
/* set the required stack size to zero (only for non-native functions) */
sym->x.stacksize=1; /* 1 for PROC opcode */
if (sym->flags & flagNAKED)
sym->x.stacksize=0; /* zero for naked functions */
else
sym->x.stacksize=1; /* 1 for PROC opcode */
} /* if */
if (pc_deprecate!=NULL) {
assert(sym!=NULL);

View File

@ -2421,8 +2421,9 @@ static int nesting=0;
/* maintain max. amount of memory used */
{
long totalsize;
totalsize=declared+decl_heap+1; /* local variables & return value size,
* +1 for PROC opcode */
totalsize=declared+decl_heap; /* local variables & return value size */
if ((sym->flags & flagNAKED)==0)
totalsize++; /* +1 for PROC opcode */
if (lval_result->ident==iREFARRAY)
totalsize++; /* add hidden parameter (on the stack) */
if ((sym->usage & uNATIVE)==0)