Commit 2ad42a82 authored by Luuk van Dijk's avatar Luuk van Dijk

gc: frame compaction for arm.

Required moving some parts of gc/pgen.c to ?g/ggen.c

on linux tests pass for all 3 architectures, and
frames are actually compacted (diagnostic code for
that has been removed from the CL).

R=rsc
CC=golang-dev
https://golang.org/cl/4571071
parent 4d0f2e91
...@@ -22,6 +22,32 @@ defframe(Prog *ptxt) ...@@ -22,6 +22,32 @@ defframe(Prog *ptxt)
maxstksize = 0; maxstksize = 0;
} }
// Sweep the prog list to mark any used nodes.
void
markautoused(Prog* p)
{
for (; p; p = p->link) {
if (p->from.name == D_AUTO && p->from.node)
p->from.node->used++;
if (p->to.name == D_AUTO && p->to.node)
p->to.node->used++;
}
}
// Fixup instructions after compactframe has moved all autos around.
void
fixautoused(Prog* p)
{
for (; p; p = p->link) {
if (p->from.name == D_AUTO && p->from.node)
p->from.offset += p->from.node->stkdelta;
if (p->to.name == D_AUTO && p->to.node)
p->to.offset += p->to.node->stkdelta;
}
}
/* /*
* generate: * generate:
* call f * call f
......
...@@ -18,6 +18,32 @@ defframe(Prog *ptxt) ...@@ -18,6 +18,32 @@ defframe(Prog *ptxt)
ptxt->to.offset |= rnd(stksize+maxarg, widthptr); ptxt->to.offset |= rnd(stksize+maxarg, widthptr);
} }
// Sweep the prog list to mark any used nodes.
void
markautoused(Prog* p)
{
for (; p; p = p->link) {
if (p->from.type == D_AUTO && p->from.node)
p->from.node->used++;
if (p->to.type == D_AUTO && p->to.node)
p->to.node->used++;
}
}
// Fixup instructions after compactframe has moved all autos around.
void
fixautoused(Prog* p)
{
for (; p; p = p->link) {
if (p->from.type == D_AUTO && p->from.node)
p->from.offset += p->from.node->stkdelta;
if (p->to.type == D_AUTO && p->to.node)
p->to.offset += p->to.node->stkdelta;
}
}
/* /*
* generate: * generate:
......
...@@ -20,6 +20,32 @@ defframe(Prog *ptxt) ...@@ -20,6 +20,32 @@ defframe(Prog *ptxt)
maxstksize = 0; maxstksize = 0;
} }
// Sweep the prog list to mark any used nodes.
void
markautoused(Prog* p)
{
for (; p; p = p->link) {
if (p->from.type == D_AUTO && p->from.node)
p->from.node->used++;
if (p->to.type == D_AUTO && p->to.node)
p->to.node->used++;
}
}
// Fixup instructions after compactframe has moved all autos around.
void
fixautoused(Prog* p)
{
for (; p; p = p->link) {
if (p->from.type == D_AUTO && p->from.node)
p->from.offset += p->from.node->stkdelta;
if (p->to.type == D_AUTO && p->to.node)
p->to.offset += p->to.node->stkdelta;
}
}
void void
clearfat(Node *nl) clearfat(Node *nl)
{ {
......
...@@ -1195,7 +1195,7 @@ void walkstmt(Node **np); ...@@ -1195,7 +1195,7 @@ void walkstmt(Node **np);
void walkstmtlist(NodeList *l); void walkstmtlist(NodeList *l);
/* /*
* arch-specific ggen.c/gsubr.c/gobj.c * arch-specific ggen.c/gsubr.c/gobj.c/pgen.c
*/ */
#define P ((Prog*)0) #define P ((Prog*)0)
...@@ -1237,6 +1237,7 @@ int dsymptr(Sym *s, int off, Sym *x, int xoff); ...@@ -1237,6 +1237,7 @@ int dsymptr(Sym *s, int off, Sym *x, int xoff);
int duintxx(Sym *s, int off, uint64 v, int wid); int duintxx(Sym *s, int off, uint64 v, int wid);
void dumpdata(void); void dumpdata(void);
void dumpfuncs(void); void dumpfuncs(void);
void fixautoused(Prog*);
void gdata(Node*, Node*, int); void gdata(Node*, Node*, int);
void gdatacomplex(Node*, Mpcplx*); void gdatacomplex(Node*, Mpcplx*);
void gdatastring(Node*, Strlit*); void gdatastring(Node*, Strlit*);
...@@ -1246,6 +1247,7 @@ void ggloblsym(Sym *s, int32 width, int dupok); ...@@ -1246,6 +1247,7 @@ void ggloblsym(Sym *s, int32 width, int dupok);
Prog* gjmp(Prog*); Prog* gjmp(Prog*);
void gused(Node*); void gused(Node*);
int isfat(Type*); int isfat(Type*);
void markautoused(Prog*);
Plist* newplist(void); Plist* newplist(void);
Node* nodarg(Type*, int); Node* nodarg(Type*, int);
void nopout(Prog*); void nopout(Prog*);
......
...@@ -111,8 +111,7 @@ compile(Node *fn) ...@@ -111,8 +111,7 @@ compile(Node *fn)
} }
oldstksize = stksize; oldstksize = stksize;
if(thechar != '5') compactframe(ptxt);
compactframe(ptxt);
if(0) if(0)
print("compactframe: %ld to %ld\n", oldstksize, stksize); print("compactframe: %ld to %ld\n", oldstksize, stksize);
...@@ -142,12 +141,12 @@ cmpstackvar(Node *a, Node *b) ...@@ -142,12 +141,12 @@ cmpstackvar(Node *a, Node *b)
} }
// TODO(lvd) find out where the PAUTO/OLITERAL nodes come from.
static void static void
compactframe(Prog* ptxt) compactframe(Prog* ptxt)
{ {
NodeList *ll; NodeList *ll;
Node* n; Node* n;
Prog *p;
uint32 w; uint32 w;
if (stksize == 0) if (stksize == 0)
...@@ -155,17 +154,10 @@ compactframe(Prog* ptxt) ...@@ -155,17 +154,10 @@ compactframe(Prog* ptxt)
// Mark the PAUTO's unused. // Mark the PAUTO's unused.
for(ll=curfn->dcl; ll != nil; ll=ll->next) for(ll=curfn->dcl; ll != nil; ll=ll->next)
if (ll->n->class == PAUTO && ll->n->op == ONAME) if (ll->n->class == PAUTO)
ll->n->used = 0; ll->n->used = 0;
// Sweep the prog list to mark any used nodes. markautoused(ptxt);
for (p = ptxt; p; p = p->link) {
if (p->from.type == D_AUTO && p->from.node)
p->from.node->used++;
if (p->to.type == D_AUTO && p->to.node)
p->to.node->used++;
}
listsort(&curfn->dcl, cmpstackvar); listsort(&curfn->dcl, cmpstackvar);
...@@ -191,7 +183,6 @@ compactframe(Prog* ptxt) ...@@ -191,7 +183,6 @@ compactframe(Prog* ptxt)
stksize = 0; stksize = 0;
for(ll = curfn->dcl; ll != nil; ll=ll->next) { for(ll = curfn->dcl; ll != nil; ll=ll->next) {
n = ll->n; n = ll->n;
// TODO find out where the literal autos come from
if (n->class != PAUTO || n->op != ONAME) if (n->class != PAUTO || n->op != ONAME)
continue; continue;
...@@ -205,14 +196,7 @@ compactframe(Prog* ptxt) ...@@ -205,14 +196,7 @@ compactframe(Prog* ptxt)
n->stkdelta = -stksize - n->xoffset; n->stkdelta = -stksize - n->xoffset;
} }
// Fixup instructions. fixautoused(ptxt);
for (p = ptxt; p; p = p->link) {
if (p->from.type == D_AUTO && p->from.node)
p->from.offset += p->from.node->stkdelta;
if (p->to.type == D_AUTO && p->to.node)
p->to.offset += p->to.node->stkdelta;
}
// The debug information needs accurate offsets on the symbols. // The debug information needs accurate offsets on the symbols.
for(ll = curfn->dcl ;ll != nil; ll=ll->next) { for(ll = curfn->dcl ;ll != nil; ll=ll->next) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment