Commit 4e141145 authored by Russ Cox's avatar Russ Cox

cmd/5c, cmd/6c, cmd/8c: record arg size for every call

R=ken2
CC=golang-dev
https://golang.org/cl/11364043
parent 9ddfb643
......@@ -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]--;
......
......@@ -298,6 +298,7 @@ int sconst(Node*);
int sval(int32);
void gpseudo(int, Sym*, Node*);
void gprefetch(Node*);
void gpcdata(int, int);
/*
* swt.c
......
......@@ -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");
......
......@@ -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)
{
......
......@@ -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) {
......
......@@ -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
......
......@@ -29,6 +29,7 @@
// THE SOFTWARE.
#include "gc.h"
#include "../../pkg/runtime/funcdata.h"
Prog*
gtext(Sym *s, int32 stkoff)
......@@ -36,8 +37,14 @@ 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");
......
......@@ -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)
{
......
......@@ -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) {
......
......@@ -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
......
......@@ -36,8 +36,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");
......
......@@ -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)
{
......
......@@ -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[];
......
......@@ -30,6 +30,17 @@
#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)
{
......
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