]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/5c, cmd/6c, cmd/8c: record arg size for every call
authorRuss Cox <rsc@golang.org>
Tue, 16 Jul 2013 20:24:43 +0000 (16:24 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 16 Jul 2013 20:24:43 +0000 (16:24 -0400)
R=ken2
CC=golang-dev
https://golang.org/cl/11364043

14 files changed:
src/cmd/5c/cgen.c
src/cmd/5c/gc.h
src/cmd/5c/sgen.c
src/cmd/5c/txt.c
src/cmd/6c/cgen.c
src/cmd/6c/gc.h
src/cmd/6c/sgen.c
src/cmd/6c/txt.c
src/cmd/8c/cgen.c
src/cmd/8c/gc.h
src/cmd/8c/sgen.c
src/cmd/8c/txt.c
src/cmd/cc/cc.h
src/cmd/cc/pgen.c

index 5ff4f633d14ac10f8f5ca96589cb1eccce844f0e..08ed36055add4cda5bcfc68dc48534927e69b203 100644 (file)
@@ -28,8 +28,8 @@
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
 
-
 #include "gc.h"
+#include "../../pkg/runtime/funcdata.h"
 
 void
 _cgen(Node *n, Node *nn, int inrel)
@@ -366,12 +366,14 @@ _cgen(Node *n, Node *nn, int inrel)
                if(REGARG >= 0)
                        o = reg[REGARG];
                gargs(r, &nod, &nod1);
+               gpcdata(PCDATA_ArgSize, curarg);
                if(l->addable < INDEXED) {
                        reglcgen(&nod, l, Z);
                        gopcode(OFUNC, Z, Z, &nod);
                        regfree(&nod);
                } else
                        gopcode(OFUNC, Z, Z, l);
+               gpcdata(PCDATA_ArgSize, -1);
                if(REGARG >= 0)
                        if(o != reg[REGARG])
                                reg[REGARG]--;
index a0fc63c608ed2bfbcc1748a9b50d4d10ab88480a..084da7e6a5470bc53f7b30d77fcd294a8ca129bd 100644 (file)
@@ -298,6 +298,7 @@ int sconst(Node*);
 int    sval(int32);
 void   gpseudo(int, Sym*, Node*);
 void   gprefetch(Node*);
+void   gpcdata(int, int);
 
 /*
  * swt.c
index 92a0f64f831caa9aa43e20bdd02ef3fac5d5c190..948791dbbaaecf18b93e35a90c20534ccff11dc4 100644 (file)
@@ -37,8 +37,13 @@ gtext(Sym *s, int32 stkoff)
        int32 a;
        
        a = 0;
-       if(!(textflag & NOSPLIT))
+       if(!(textflag & NOSPLIT) || !hasdotdotdot()) {
                a = argsize();
+               // Change argsize 0 to 1 to be mark that
+               // the argument size is present.
+               if(a == 0)
+                       a = 1;
+       }
        else if(stkoff >= 128)
                yyerror("stack frame too large for NOSPLIT function");
 
index 8dfd586fd4a3abd59545994851254cfd39ff4687..81da9fb8010539929c207ed7f07fa21f74470598 100644 (file)
@@ -1197,6 +1197,15 @@ gpseudo(int a, Sym *s, Node *n)
                pc--;
 }
 
+void
+gpcdata(int index, int value)
+{
+       Node n1;
+       
+       n1 = *nodconst(index);
+       gins(APCDATA, &n1, nodconst(value));
+}
+
 void
 gprefetch(Node *n)
 {
index e5887a315fe1df4ce2adfbd42c7fc36c38c7ad73..bdef76ff08c3f0e88a565ec795b447c2c68ff980 100644 (file)
@@ -29,6 +29,7 @@
 // THE SOFTWARE.
 
 #include "gc.h"
+#include "../../pkg/runtime/funcdata.h"
 
 /* ,x/^(print|prtree)\(/i/\/\/ */
 int castup(Type*, Type*);
@@ -944,6 +945,7 @@ cgen(Node *n, Node *nn)
                        return;
                }
                gargs(r, &nod, &nod1);
+               gpcdata(PCDATA_ArgSize, curarg);
                if(l->addable < INDEXED) {
                        reglcgen(&nod, l, nn);
                        nod.op = OREGISTER;
@@ -951,6 +953,7 @@ cgen(Node *n, Node *nn)
                        regfree(&nod);
                } else
                        gopcode(OFUNC, n->type, Z, l);
+               gpcdata(PCDATA_ArgSize, -1);
                if(REGARG >= 0 && reg[REGARG])
                        reg[REGARG]--;
                if(nn != Z) {
index d1133ee21488b58df280c36e7c962e71ef15c0d4..c466a3afe2a9d6f13ae0d27fb0d59b3ceec8f02e 100644 (file)
@@ -293,6 +293,7 @@ void        patch(Prog*, int32);
 int    sconst(Node*);
 void   gpseudo(int, Sym*, Node*);
 void   gprefetch(Node*);
+void   gpcdata(int, int);
 
 /*
  * swt.c
index 2402a020da34e78f2a4c0219431a3da273db4efa..99c05ecc4e7b42932c7f4f4b79167c2086fcd254 100644 (file)
 // THE SOFTWARE.
 
 #include "gc.h"
+#include "../../pkg/runtime/funcdata.h"
 
 Prog*
 gtext(Sym *s, int32 stkoff)
 {
        vlong v;
-       
+
        v = 0;
-       if(!(textflag & NOSPLIT))
-               v |= argsize() << 32;
+       if(!(textflag & NOSPLIT) || !hasdotdotdot()) {
+               v = argsize();
+               // Change argsize 0 to 1 to be mark that
+               // the argument size is present.
+               if(v == 0)
+                       v = 1;
+               v <<= 32;
+       }
        v |= stkoff & 0xffffffff;
        if((textflag & NOSPLIT) && stkoff >= 128)
                yyerror("stack frame too large for NOSPLIT function");
index b91e22b399bd63fe32fac56a7d83d597871657a3..6f5d42da578af380e7e0820c3c993b4fc905aafc 100644 (file)
@@ -1518,6 +1518,15 @@ gpseudo(int a, Sym *s, Node *n)
                pc--;
 }
 
+void
+gpcdata(int index, int value)
+{
+       Node n1;
+       
+       n1 = *nodconst(index);
+       gins(APCDATA, &n1, nodconst(value));
+}
+
 void
 gprefetch(Node *n)
 {
index 4d4ae13abeebe1d6b63cc3e5885973393cb3f5fa..f54102245632fd7bdbc0a326355ed8f7fa53e964 100644 (file)
@@ -29,6 +29,7 @@
 // THE SOFTWARE.
 
 #include "gc.h"
+#include "../../pkg/runtime/funcdata.h"
 
 /* ,x/^(print|prtree)\(/i/\/\/ */
 
@@ -937,6 +938,7 @@ cgen(Node *n, Node *nn)
                        return;
                }
                gargs(r, &nod, &nod1);
+               gpcdata(PCDATA_ArgSize, curarg);
                if(l->addable < INDEXED) {
                        reglcgen(&nod, l, nn);
                        nod.op = OREGISTER;
@@ -944,6 +946,7 @@ cgen(Node *n, Node *nn)
                        regfree(&nod);
                } else
                        gopcode(OFUNC, n->type, Z, l);
+               gpcdata(PCDATA_ArgSize, -1);
                if(REGARG >= 0 && reg[REGARG])
                        reg[REGARG]--;
                if(nn != Z) {
index bdf981b4c213650e4ebe18554554898fbf355a96..b668b4c63939ed17b22cca5c20cbdf6cd487f457 100644 (file)
@@ -298,6 +298,7 @@ void        patch(Prog*, int32);
 int    sconst(Node*);
 void   gpseudo(int, Sym*, Node*);
 void   gprefetch(Node*);
+void   gpcdata(int, int);
 
 /*
  * swt.c
index b0f2bc544c4f14349365c9155722a0767534b82f..f3c7e32f349f022e54fa62f7e6aa3261a3978c57 100644 (file)
@@ -34,10 +34,15 @@ Prog*
 gtext(Sym *s, int32 stkoff)
 {
        int32 a;
-       
+
        a = 0;
-       if(!(textflag & NOSPLIT))
+       if(!(textflag & NOSPLIT) || !hasdotdotdot()) {
                a = argsize();
+               // Change argsize 0 to 1 to be mark that
+               // the argument size is present.
+               if(a == 0)
+                       a = 1;
+       }
        else if(stkoff >= 128)
                yyerror("stack frame too large for NOSPLIT function");
 
index 721322a531e6fc9fd705fcb04d2d81c777c4465d..5c486af38d5049f9c918f752bdd12d028eb815b7 100644 (file)
@@ -1397,6 +1397,15 @@ gpseudo(int a, Sym *s, Node *n)
                pc--;
 }
 
+void
+gpcdata(int index, int value)
+{
+       Node n1;
+       
+       n1 = *nodconst(index);
+       gins(APCDATA, &n1, nodconst(value));
+}
+
 void
 gprefetch(Node *n)
 {
index 535e22d6f6c3085f862841ccb390c42fac32e689..fe9f9f79854ee8cc1749ed39491d60391c50f799 100644 (file)
@@ -777,6 +777,7 @@ void        xcom(Node*);
 int32  exreg(Type*);
 int32  align(int32, Type*, int, int32*);
 int32  maxround(int32, int32);
+int    hasdotdotdot(void);
 
 extern schar   ewidth[];
 
index 628f858b632a372aeeac240935502b5cdea00c2d..ee7b0c57f86409f15d3543d3f8ea9a4630445016 100644 (file)
 
 #include "gc.h"
 
+int
+hasdotdotdot(void)
+{
+       Type *t;
+
+       for(t=thisfn->down; t!=T; t=t->down)
+               if(t->etype == TDOT)
+                       return 1;
+       return 0;
+}
+
 vlong
 argsize(void)
 {