Commit 175c4015 authored by Jan Ziak's avatar Jan Ziak

cmd/gc: unroll small array types

R=golang-dev, rsc
CC=golang-dev, nigeltao
https://golang.org/cl/7812044
parent 5146a93e
...@@ -1025,11 +1025,24 @@ dalgsym(Type *t) ...@@ -1025,11 +1025,24 @@ dalgsym(Type *t)
return s; return s;
} }
static int
gcinline(Type *t) {
switch(t->etype) {
case TARRAY:
if(t->bound == 1)
return 1;
if(t->width <= 4*widthptr)
return 1;
break;
}
return 0;
}
static int static int
dgcsym1(Sym *s, int ot, Type *t, vlong *off, int stack_size) dgcsym1(Sym *s, int ot, Type *t, vlong *off, int stack_size)
{ {
Type *t1; Type *t1;
vlong o, off2, fieldoffset; vlong o, off2, fieldoffset, i;
if(t->align > 0 && (*off % t->align) != 0) if(t->align > 0 && (*off % t->align) != 0)
fatal("dgcsym1: invalid initial alignment, %T", t); fatal("dgcsym1: invalid initial alignment, %T", t);
...@@ -1132,7 +1145,8 @@ dgcsym1(Sym *s, int ot, Type *t, vlong *off, int stack_size) ...@@ -1132,7 +1145,8 @@ dgcsym1(Sym *s, int ot, Type *t, vlong *off, int stack_size)
} else { } else {
if(t->bound < 1 || !haspointers(t->type)) { if(t->bound < 1 || !haspointers(t->type)) {
*off += t->width; *off += t->width;
} else if(t->bound == 1) { } else if(gcinline(t)) {
for(i=0; i<t->bound; i++)
ot = dgcsym1(s, ot, t->type, off, stack_size); // recursive call of dgcsym1 ot = dgcsym1(s, ot, t->type, off, stack_size); // recursive call of dgcsym1
} else { } else {
if(stack_size < GC_STACK_CAPACITY) { if(stack_size < GC_STACK_CAPACITY) {
......
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