mirror of https://github.com/golang/go.git
cmd/5c, cmd/6c, cmd/8c: record arg size for every call
R=ken2 CC=golang-dev https://golang.org/cl/11364043
This commit is contained in:
parent
9ddfb64365
commit
4e141145b7
|
|
@ -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,15 +29,22 @@
|
|||
// 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");
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue