Commit ffb07c0e authored by Russ Cox's avatar Russ Cox

[dev.power64] all: merge default, for codereview update

LGTM=minux
R=minux
CC=golang-codereviews
https://golang.org/cl/124820043
parents 245ed93c 2185dbcd
...@@ -308,18 +308,13 @@ class CL(object): ...@@ -308,18 +308,13 @@ class CL(object):
os.unlink(dir + "/cl." + self.name) os.unlink(dir + "/cl." + self.name)
def Subject(self, ui, repo): def Subject(self, ui, repo):
branchPrefix = ""
branch = repo[None].branch()
if branch.startswith("dev."):
branchPrefix = "[" + branch + "] "
s = line1(self.desc) s = line1(self.desc)
if len(s) > 60: if len(s) > 60:
s = s[0:55] + "..." s = s[0:55] + "..."
if self.name != "new": if self.name != "new":
s = "code review %s: %s" % (self.name, s) s = "code review %s: %s" % (self.name, s)
typecheck(s, str) typecheck(s, str)
return branchPrefix + s return branch_prefix(ui, repo) + s
def Upload(self, ui, repo, send_mail=False, gofmt=True, gofmt_just_warn=False, creating=False, quiet=False): def Upload(self, ui, repo, send_mail=False, gofmt=True, gofmt_just_warn=False, creating=False, quiet=False):
if not self.files and not creating: if not self.files and not creating:
...@@ -394,6 +389,8 @@ class CL(object): ...@@ -394,6 +389,8 @@ class CL(object):
if vcs: if vcs:
set_status("uploading base files") set_status("uploading base files")
vcs.UploadBaseFiles(issue, rpc, patches, patchset, upload_options, files) vcs.UploadBaseFiles(issue, rpc, patches, patchset, upload_options, files)
if patchset != "1":
MySend("/" + issue + "/upload_complete/" + patchset, payload="")
if send_mail: if send_mail:
set_status("sending mail") set_status("sending mail")
MySend("/" + issue + "/mail", payload="") MySend("/" + issue + "/mail", payload="")
...@@ -1921,6 +1918,13 @@ def pending(ui, repo, *pats, **opts): ...@@ -1921,6 +1918,13 @@ def pending(ui, repo, *pats, **opts):
def need_sync(): def need_sync():
raise hg_util.Abort("local repository out of date; must sync before submit") raise hg_util.Abort("local repository out of date; must sync before submit")
def branch_prefix(ui, repo):
prefix = ""
branch = repo[None].branch()
if branch.startswith("dev."):
prefix = "[" + branch + "] "
return prefix
@hgcommand @hgcommand
def submit(ui, repo, *pats, **opts): def submit(ui, repo, *pats, **opts):
"""submit change to remote repository """submit change to remote repository
...@@ -1990,7 +1994,7 @@ def submit(ui, repo, *pats, **opts): ...@@ -1990,7 +1994,7 @@ def submit(ui, repo, *pats, **opts):
cl.Mail(ui, repo) cl.Mail(ui, repo)
# submit changes locally # submit changes locally
message = cl.desc.rstrip() + "\n\n" + about message = branch_prefix(ui, repo) + cl.desc.rstrip() + "\n\n" + about
typecheck(message, str) typecheck(message, str)
set_status("pushing " + cl.name + " to remote server") set_status("pushing " + cl.name + " to remote server")
...@@ -2000,12 +2004,22 @@ def submit(ui, repo, *pats, **opts): ...@@ -2000,12 +2004,22 @@ def submit(ui, repo, *pats, **opts):
old_heads = len(hg_heads(ui, repo).split()) old_heads = len(hg_heads(ui, repo).split())
# Normally we commit listing the specific files in the CL.
# If there are no changed files other than those in the CL, however,
# let hg build the list, because then committing a merge works.
# (You cannot name files for a merge commit, even if you name
# all the files that would be committed by not naming any.)
files = ['path:'+f for f in cl.files]
if ChangedFiles(ui, repo, []) == cl.files:
files = []
global commit_okay global commit_okay
commit_okay = True commit_okay = True
ret = hg_commit(ui, repo, *['path:'+f for f in cl.files], message=message, user=userline) ret = hg_commit(ui, repo, *files, message=message, user=userline)
commit_okay = False commit_okay = False
if ret: if ret:
raise hg_util.Abort("nothing changed") raise hg_util.Abort("nothing changed")
node = repo["-1"].node() node = repo["-1"].node()
# push to remote; if it fails for any reason, roll back # push to remote; if it fails for any reason, roll back
try: try:
......
...@@ -108,20 +108,6 @@ arrayadd(Array *array, void *element) ...@@ -108,20 +108,6 @@ arrayadd(Array *array, void *element)
arrayset(array, array->length - 1, element); arrayset(array, array->length - 1, element);
} }
int32
arrayindexof(Array *array, void *element)
{
void *p;
int32 i;
for(i = 0; i < array->length; i++) {
p = arrayget(array, i);
if(memcmp(p, &element, array->size) == 0)
return i;
}
return -1;
}
void void
arraysort(Array *array, int (*cmp)(const void*, const void*)) arraysort(Array *array, int (*cmp)(const void*, const void*))
{ {
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
enum { enum {
WORDSIZE = sizeof(uint32), WORDSIZE = sizeof(uint32),
WORDBITS = 32, WORDBITS = 32,
WORDMASK = WORDBITS - 1,
WORDSHIFT = 5,
}; };
static uintptr static uintptr
...@@ -94,13 +96,35 @@ bvconcat(Bvec *src1, Bvec *src2) ...@@ -94,13 +96,35 @@ bvconcat(Bvec *src1, Bvec *src2)
int int
bvget(Bvec *bv, int32 i) bvget(Bvec *bv, int32 i)
{ {
uint32 mask, word;
if(i < 0 || i >= bv->n) if(i < 0 || i >= bv->n)
fatal("bvget: index %d is out of bounds with length %d\n", i, bv->n); fatal("bvget: index %d is out of bounds with length %d\n", i, bv->n);
mask = 1U << (i % WORDBITS); return (bv->b[i>>WORDSHIFT] >> (i&WORDMASK)) & 1;
word = bv->b[i / WORDBITS] & mask; }
return word ? 1 : 0;
// bvnext returns the smallest index >= i for which bvget(bv, i) == 1.
// If there is no such index, bvnext returns -1.
int
bvnext(Bvec *bv, int32 i)
{
uint32 w;
// Jump i ahead to next word with bits.
if((bv->b[i>>WORDSHIFT]>>(i&WORDMASK)) == 0) {
i &= ~WORDMASK;
i += WORDBITS;
while(i < bv->n && bv->b[i>>WORDSHIFT] == 0)
i += WORDBITS;
}
if(i >= bv->n)
return -1;
// Find 1 bit.
w = bv->b[i>>WORDSHIFT]>>(i&WORDMASK);
while((w&1) == 0) {
w>>=1;
i++;
}
return i;
} }
int int
...@@ -109,7 +133,7 @@ bvisempty(Bvec *bv) ...@@ -109,7 +133,7 @@ bvisempty(Bvec *bv)
int32 i; int32 i;
for(i = 0; i < bv->n; i += WORDBITS) for(i = 0; i < bv->n; i += WORDBITS)
if(bv->b[i / WORDBITS] != 0) if(bv->b[i>>WORDSHIFT] != 0)
return 0; return 0;
return 1; return 1;
} }
......
...@@ -1017,7 +1017,6 @@ int32 arraylength(Array *array); ...@@ -1017,7 +1017,6 @@ int32 arraylength(Array *array);
void* arrayget(Array *array, int32 index); void* arrayget(Array *array, int32 index);
void arrayset(Array *array, int32 index, void *element); void arrayset(Array *array, int32 index, void *element);
void arrayadd(Array *array, void *element); void arrayadd(Array *array, void *element);
int32 arrayindexof(Array* array, void *element);
void arraysort(Array* array, int (*cmp)(const void*, const void*)); void arraysort(Array* array, int (*cmp)(const void*, const void*));
/* /*
...@@ -1043,6 +1042,7 @@ int bvcmp(Bvec *bv1, Bvec *bv2); ...@@ -1043,6 +1042,7 @@ int bvcmp(Bvec *bv1, Bvec *bv2);
void bvcopy(Bvec *dst, Bvec *src); void bvcopy(Bvec *dst, Bvec *src);
Bvec* bvconcat(Bvec *src1, Bvec *src2); Bvec* bvconcat(Bvec *src1, Bvec *src2);
int bvget(Bvec *bv, int32 i); int bvget(Bvec *bv, int32 i);
int32 bvnext(Bvec *bv, int32 i);
int bvisempty(Bvec *bv); int bvisempty(Bvec *bv);
void bvnot(Bvec *bv); void bvnot(Bvec *bv);
void bvor(Bvec *dst, Bvec *src1, Bvec *src2); void bvor(Bvec *dst, Bvec *src1, Bvec *src2);
......
...@@ -283,13 +283,30 @@ getvariables(Node *fn) ...@@ -283,13 +283,30 @@ getvariables(Node *fn)
// For arguments and results, the bitmap covers all variables, // For arguments and results, the bitmap covers all variables,
// so we must include all the variables, even the ones without // so we must include all the variables, even the ones without
// pointers. // pointers.
//
// The Node.opt field is available for use by optimization passes.
// We use it to hold the index of the node in the variables array, plus 1
// (so that 0 means the Node is not in the variables array).
// Each pass should clear opt when done, but you never know,
// so clear them all ourselves too.
// The Node.curfn field is supposed to be set to the current function
// already, but for some compiler-introduced names it seems not to be,
// so fix that here.
// Later, when we want to find the index of a node in the variables list,
// we will check that n->curfn == curfn and n->opt > 0. Then n->opt - 1
// is the index in the variables list.
ll->n->opt = nil;
ll->n->curfn = curfn;
switch(ll->n->class) { switch(ll->n->class) {
case PAUTO: case PAUTO:
if(haspointers(ll->n->type)) if(haspointers(ll->n->type)) {
ll->n->opt = (void*)(uintptr)(arraylength(result)+1);
arrayadd(result, &ll->n); arrayadd(result, &ll->n);
}
break; break;
case PPARAM: case PPARAM:
case PPARAMOUT: case PPARAMOUT:
ll->n->opt = (void*)(uintptr)(arraylength(result)+1);
arrayadd(result, &ll->n); arrayadd(result, &ll->n);
break; break;
} }
...@@ -718,14 +735,16 @@ progeffects(Prog *prog, Array *vars, Bvec *uevar, Bvec *varkill, Bvec *avarinit) ...@@ -718,14 +735,16 @@ progeffects(Prog *prog, Array *vars, Bvec *uevar, Bvec *varkill, Bvec *avarinit)
} }
if(info.flags & (LeftRead | LeftWrite | LeftAddr)) { if(info.flags & (LeftRead | LeftWrite | LeftAddr)) {
from = &prog->from; from = &prog->from;
if (from->node != nil && from->sym != nil) { if (from->node != nil && from->sym != nil && from->node->curfn == curfn) {
switch(from->node->class & ~PHEAP) { switch(from->node->class & ~PHEAP) {
case PAUTO: case PAUTO:
case PPARAM: case PPARAM:
case PPARAMOUT: case PPARAMOUT:
pos = arrayindexof(vars, from->node); pos = (int)(uintptr)from->node->opt - 1; // index in vars
if(pos == -1) if(pos == -1)
goto Next; goto Next;
if(pos >= arraylength(vars) || *(Node**)arrayget(vars, pos) != from->node)
fatal("bad bookkeeping in liveness %N %d", from->node, pos);
if(from->node->addrtaken) { if(from->node->addrtaken) {
bvset(avarinit, pos); bvset(avarinit, pos);
} else { } else {
...@@ -741,14 +760,16 @@ progeffects(Prog *prog, Array *vars, Bvec *uevar, Bvec *varkill, Bvec *avarinit) ...@@ -741,14 +760,16 @@ progeffects(Prog *prog, Array *vars, Bvec *uevar, Bvec *varkill, Bvec *avarinit)
Next: Next:
if(info.flags & (RightRead | RightWrite | RightAddr)) { if(info.flags & (RightRead | RightWrite | RightAddr)) {
to = &prog->to; to = &prog->to;
if (to->node != nil && to->sym != nil) { if (to->node != nil && to->sym != nil && to->node->curfn == curfn) {
switch(to->node->class & ~PHEAP) { switch(to->node->class & ~PHEAP) {
case PAUTO: case PAUTO:
case PPARAM: case PPARAM:
case PPARAMOUT: case PPARAMOUT:
pos = arrayindexof(vars, to->node); pos = (int)(uintptr)to->node->opt - 1; // index in vars
if(pos == -1) if(pos == -1)
goto Next1; goto Next1;
if(pos >= arraylength(vars) || *(Node**)arrayget(vars, pos) != to->node)
fatal("bad bookkeeping in liveness %N %d", to->node, pos);
if(to->node->addrtaken) { if(to->node->addrtaken) {
if(prog->as != AVARKILL) if(prog->as != AVARKILL)
bvset(avarinit, pos); bvset(avarinit, pos);
...@@ -1020,6 +1041,9 @@ checkptxt(Node *fn, Prog *firstp) ...@@ -1020,6 +1041,9 @@ checkptxt(Node *fn, Prog *firstp)
{ {
Prog *p; Prog *p;
if(debuglive == 0)
return;
for(p = firstp; p != P; p = p->link) { for(p = firstp; p != P; p = p->link) {
if(0) if(0)
print("analyzing '%P'\n", p); print("analyzing '%P'\n", p);
...@@ -1172,21 +1196,17 @@ twobitlivepointermap(Liveness *lv, Bvec *liveout, Array *vars, Bvec *args, Bvec ...@@ -1172,21 +1196,17 @@ twobitlivepointermap(Liveness *lv, Bvec *liveout, Array *vars, Bvec *args, Bvec
vlong xoffset; vlong xoffset;
int32 i; int32 i;
for(i = 0; i < arraylength(vars); i++) { for(i = 0; (i = bvnext(liveout, i)) >= 0; i++) {
node = *(Node**)arrayget(vars, i); node = *(Node**)arrayget(vars, i);
switch(node->class) { switch(node->class) {
case PAUTO: case PAUTO:
if(bvget(liveout, i)) { xoffset = node->xoffset + stkptrsize;
xoffset = node->xoffset + stkptrsize; twobitwalktype1(node->type, &xoffset, locals);
twobitwalktype1(node->type, &xoffset, locals);
}
break; break;
case PPARAM: case PPARAM:
case PPARAMOUT: case PPARAMOUT:
if(bvget(liveout, i)) { xoffset = node->xoffset;
xoffset = node->xoffset; twobitwalktype1(node->type, &xoffset, args);
twobitwalktype1(node->type, &xoffset, args);
}
break; break;
} }
} }
...@@ -1944,6 +1964,7 @@ liveness(Node *fn, Prog *firstp, Sym *argssym, Sym *livesym) ...@@ -1944,6 +1964,7 @@ liveness(Node *fn, Prog *firstp, Sym *argssym, Sym *livesym)
Array *cfg, *vars; Array *cfg, *vars;
Liveness *lv; Liveness *lv;
int debugdelta; int debugdelta;
NodeList *l;
// Change name to dump debugging information only for a specific function. // Change name to dump debugging information only for a specific function.
debugdelta = 0; debugdelta = 0;
...@@ -1984,6 +2005,9 @@ liveness(Node *fn, Prog *firstp, Sym *argssym, Sym *livesym) ...@@ -1984,6 +2005,9 @@ liveness(Node *fn, Prog *firstp, Sym *argssym, Sym *livesym)
twobitwritesymbol(lv->argslivepointers, argssym); twobitwritesymbol(lv->argslivepointers, argssym);
// Free everything. // Free everything.
for(l=fn->dcl; l != nil; l = l->next)
if(l->n != N)
l->n->opt = nil;
freeliveness(lv); freeliveness(lv);
arrayfree(vars); arrayfree(vars);
freecfg(cfg); freecfg(cfg);
......
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