Commit 45fe306a authored by Rémy Oudompheng's avatar Rémy Oudompheng

cmd/[568]g: recycle ONAME nodes used in regopt to denote registers.

The reported decrease in memory usage is about 5%.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6902064
parent 00cd6a3b
......@@ -170,6 +170,8 @@ static char* regname[] = {
".F15",
};
static Node* regnodes[NREGVAR];
void
regopt(Prog *firstp)
{
......@@ -216,8 +218,11 @@ regopt(Prog *firstp)
*/
nvar = NREGVAR;
memset(var, 0, NREGVAR*sizeof var[0]);
for(i=0; i<NREGVAR; i++)
var[i].node = newname(lookup(regname[i]));
for(i=0; i<NREGVAR; i++) {
if(regnodes[i] == N)
regnodes[i] = newname(lookup(regname[i]));
var[i].node = regnodes[i];
}
regbits = RtoB(REGSP)|RtoB(REGLINK)|RtoB(REGPC);
for(z=0; z<BITS; z++) {
......
......@@ -151,6 +151,8 @@ static char* regname[] = {
".X15",
};
static Node* regnodes[NREGVAR];
static void fixjmp(Prog*);
void
......@@ -191,8 +193,11 @@ regopt(Prog *firstp)
*/
nvar = NREGVAR;
memset(var, 0, NREGVAR*sizeof var[0]);
for(i=0; i<NREGVAR; i++)
var[i].node = newname(lookup(regname[i]));
for(i=0; i<NREGVAR; i++) {
if(regnodes[i] == N)
regnodes[i] = newname(lookup(regname[i]));
var[i].node = regnodes[i];
}
regbits = RtoB(D_SP);
for(z=0; z<BITS; z++) {
......
......@@ -121,6 +121,8 @@ setaddrs(Bits bit)
static char* regname[] = { ".ax", ".cx", ".dx", ".bx", ".sp", ".bp", ".si", ".di" };
static Node* regnodes[NREGVAR];
void
regopt(Prog *firstp)
{
......@@ -159,8 +161,11 @@ regopt(Prog *firstp)
*/
nvar = NREGVAR;
memset(var, 0, NREGVAR*sizeof var[0]);
for(i=0; i<NREGVAR; i++)
var[i].node = newname(lookup(regname[i]));
for(i=0; i<NREGVAR; i++) {
if(regnodes[i] == N)
regnodes[i] = newname(lookup(regname[i]));
var[i].node = regnodes[i];
}
regbits = RtoB(D_SP);
for(z=0; z<BITS; z++) {
......
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