]> Cypherpunks repositories - gostls13.git/commitdiff
gc: frame compaction for arm.
authorLuuk van Dijk <lvd@golang.org>
Tue, 14 Jun 2011 15:03:37 +0000 (17:03 +0200)
committerLuuk van Dijk <lvd@golang.org>
Tue, 14 Jun 2011 15:03:37 +0000 (17:03 +0200)
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

src/cmd/5g/ggen.c
src/cmd/6g/ggen.c
src/cmd/8g/ggen.c
src/cmd/gc/go.h
src/cmd/gc/pgen.c

index 0bc1b38fc4c6657f64d0d54860c57e2577d2729d..b19698cbd7106386ebfbc1fe9b2f8775b236d619 100644 (file)
@@ -22,6 +22,32 @@ defframe(Prog *ptxt)
        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:
  *     call f
index 5260335df75a1a5c229d8eda47721b5f1267f314..7922b2145f27a05e4e8e0353dd105998152e2da8 100644 (file)
@@ -18,6 +18,32 @@ defframe(Prog *ptxt)
        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:
index 25adb38c0c14c468642adca0a23f6911919da483..89a5e42697e95eed760e5e144bdcd185879b3587 100644 (file)
@@ -20,6 +20,32 @@ defframe(Prog *ptxt)
        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
 clearfat(Node *nl)
 {
index 86db48391faca3f8c9023a7e0c7e5a86b1b3d40c..2dfcb1669be178c559360e7faa6a4f03f3020d4a 100644 (file)
@@ -1195,7 +1195,7 @@ void      walkstmt(Node **np);
 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)
 
@@ -1237,6 +1237,7 @@ int       dsymptr(Sym *s, int off, Sym *x, int xoff);
 int    duintxx(Sym *s, int off, uint64 v, int wid);
 void   dumpdata(void);
 void   dumpfuncs(void);
+void   fixautoused(Prog*);
 void   gdata(Node*, Node*, int);
 void   gdatacomplex(Node*, Mpcplx*);
 void   gdatastring(Node*, Strlit*);
@@ -1246,6 +1247,7 @@ void      ggloblsym(Sym *s, int32 width, int dupok);
 Prog*  gjmp(Prog*);
 void   gused(Node*);
 int    isfat(Type*);
+void   markautoused(Prog*);
 Plist* newplist(void);
 Node*  nodarg(Type*, int);
 void   nopout(Prog*);
index ab6186697352b215d82196dd3f6851502759b9dc..9a8fa3138860218a869106718ce2a98fcd590bff 100644 (file)
@@ -111,8 +111,7 @@ compile(Node *fn)
        }
 
        oldstksize = stksize;
-       if(thechar != '5')
-               compactframe(ptxt);
+       compactframe(ptxt);
        if(0)
                print("compactframe: %ld to %ld\n", oldstksize, stksize);
 
@@ -142,12 +141,12 @@ cmpstackvar(Node *a, Node *b)
 
 }
 
+// TODO(lvd) find out where the PAUTO/OLITERAL nodes come from.
 static void
 compactframe(Prog* ptxt)
 {
        NodeList *ll;
        Node* n;
-       Prog *p;
        uint32 w;
 
        if (stksize == 0)
@@ -155,17 +154,10 @@ compactframe(Prog* ptxt)
 
        // Mark the PAUTO's unused.
        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;
 
-       // Sweep the prog list to mark any used nodes.
-       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++;
-       }
+       markautoused(ptxt);
 
        listsort(&curfn->dcl, cmpstackvar);
 
@@ -191,7 +183,6 @@ compactframe(Prog* ptxt)
        stksize = 0;
        for(ll = curfn->dcl; ll != nil; ll=ll->next) {
                n = ll->n;
-               // TODO find out where the literal autos come from
                if (n->class != PAUTO || n->op != ONAME)
                        continue;
 
@@ -205,14 +196,7 @@ compactframe(Prog* ptxt)
                n->stkdelta = -stksize - n->xoffset;
        }
 
-       // Fixup instructions.
-       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;
-       }
+       fixautoused(ptxt);
 
        // The debug information needs accurate offsets on the symbols.
        for(ll = curfn->dcl ;ll != nil; ll=ll->next) {