Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't allocate space for frame pointer if not using frame pointer #9620

Merged
merged 1 commit into from Apr 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 34 additions & 6 deletions src/dmd/backend/cgcod.d
Expand Up @@ -12,6 +12,8 @@

module dmd.backend.cgcod;

version = FRAMEPTR;

version (SCPP)
version = COMPILE;
version (MARS)
Expand Down Expand Up @@ -768,7 +770,10 @@ void prolog(ref CodeBuilder cdb)
//printf("cod3.prolog() %s, needframe = %d, Auto.alignment = %d\n", funcsym_p.Sident, needframe, Auto.alignment);
debug debugw && printf("funcstart()\n");
regcon.immed.mval = 0; /* no values in registers yet */
EBPtoESP = -REGSIZE;
version (FRAMEPTR)
EBPtoESP = 0;
else
EBPtoESP = -REGSIZE;
hasframe = 0;
bool pushds = false;
BPoff = 0;
Expand Down Expand Up @@ -842,7 +847,16 @@ Lagain:
if (tym == TYifunc)
Para.size = 26; // how is this number derived?
else
Para.size = (farfunc ? 3 : 2) * REGSIZE;
{
version (FRAMEPTR)
{
Para.size = ((farfunc ? 2 : 1) + needframe) * REGSIZE;
if (needframe)
EBPtoESP = -REGSIZE;
}
else
Para.size = ((farfunc ? 2 : 1) + 1) * REGSIZE;
}

/* The real reason for the FAST section is because the implementation of contracts
* requires a consistent stack frame location for the 'this' pointer. But if varying
Expand Down Expand Up @@ -890,8 +904,11 @@ Lagain:
* defined and on other platforms, it is never set. Because of that
* the value of neadframe should always be the same for the overridden
* and the overriding function, and so bias should be the same too.
*/
*/

version (FRAMEPTR)
int bias = enforcealign ? 0 : cast(int)(Para.size);
else
int bias = enforcealign ? 0 : cast(int)(Para.size + (needframe ? 0 : REGSIZE));

if (Fast.alignment < REGSIZE)
Expand Down Expand Up @@ -968,7 +985,12 @@ Lagain:

int sz = cast(int)(localsize + npush * REGSIZE);
if (!enforcealign)
sz += Para.size + (needframe ? 0 : -REGSIZE);
{
version (FRAMEPTR)
sz += Para.size;
else
sz += Para.size + (needframe ? 0 : -REGSIZE);
}
if (sz & (STACKALIGN - 1))
localsize += STACKALIGN - (sz & (STACKALIGN - 1));
}
Expand Down Expand Up @@ -1062,7 +1084,8 @@ Lagain:
{
assert(I32 || I64);
prolog_frameadj2(cdbx, tyf, xlocalsize, &pushalloc);
BPoff += REGSIZE;
version (FRAMEPTR) { } else
BPoff += REGSIZE;
}
else
assert((localsize | Alloca.size) == 0 || (usednteh & NTEHjmonitor));
Expand Down Expand Up @@ -1097,7 +1120,12 @@ Lagain:
uint spalign = 0;
int sz = cast(int)localsize;
if (!enforcealign)
sz += Para.size + (needframe ? 0 : -REGSIZE);
{
version (FRAMEPTR)
sz += Para.size;
else
sz += Para.size + (needframe ? 0 : -REGSIZE);
}
if (STACKALIGN >= 16 && (sz & (STACKALIGN - 1)))
spalign = STACKALIGN - (sz & (STACKALIGN - 1));

Expand Down