Commit ca2d32b4 authored by Carl Shapiro's avatar Carl Shapiro

undo CL 12785045 / 71ce80dc4195

This has broken the 32-bit builds.

««« original CL description
cmd/gc, runtime: use type information to scan interface values

R=golang-dev, rsc, dvyukov
CC=golang-dev
https://golang.org/cl/12785045
»»»

R=khr, golang-dev, khr
CC=golang-dev
https://golang.org/cl/13010045
parent 0d5bc0cf
......@@ -257,6 +257,7 @@ walktype1(Type *t, vlong *xoffset, Bvec *bv)
bvset(bv, ((*xoffset / widthptr) * BitsPerPointer) + 1);
if(isnilinter(t))
bvset(bv, ((*xoffset / widthptr) * BitsPerPointer));
bvset(bv, ((*xoffset + widthptr) / widthptr) * BitsPerPointer);
*xoffset += t->width;
break;
......
......@@ -36,10 +36,6 @@ enum {
// Pointer map
BitsPerPointer = 2,
BitsNoPointer = 0,
BitsPointer = 1,
BitsIface = 2,
BitsEface = 3,
};
// Bits in per-word bitmap.
......@@ -1402,52 +1398,26 @@ struct BitVector
uint32 data[];
};
// Scans an interface data value when the interface type indicates
// that it is a pointer.
static void
scaninterfacedata(uintptr bits, byte *scanp, bool inprologue)
{
Itab *tab;
Type *type;
if(!inprologue) {
if(bits == BitsIface) {
tab = *(Itab**)scanp;
if(tab->type->size <= sizeof(void*) && (tab->type->kind & KindNoPointers))
return;
} else { // bits == BitsEface
type = *(Type**)scanp;
if(type->size <= sizeof(void*) && (type->kind & KindNoPointers))
return;
}
}
addroot((Obj){scanp+PtrSize, PtrSize, 0});
}
// Starting from scanp, scans words corresponding to set bits.
static void
scanbitvector(byte *scanp, BitVector *bv, bool inprologue)
scanbitvector(byte *scanp, BitVector *bv)
{
uintptr word, bits;
uint32 *wordp;
uint32 *wp;
uint32 w;
int32 i, remptrs;
wordp = bv->data;
wp = bv->data;
for(remptrs = bv->n; remptrs > 0; remptrs -= 32) {
word = *wordp++;
w = *wp++;
if(remptrs < 32)
i = remptrs;
else
i = 32;
i /= BitsPerPointer;
for(; i > 0; i--) {
bits = word & 3;
if(bits != BitsNoPointer && *(void**)scanp != nil)
if(bits == BitsPointer)
addroot((Obj){scanp, PtrSize, 0});
else
scaninterfacedata(bits, scanp, inprologue);
word >>= BitsPerPointer;
if(w & 3)
addroot((Obj){scanp, PtrSize, 0});
w >>= BitsPerPointer;
scanp += PtrSize;
}
}
......@@ -1460,14 +1430,12 @@ addframeroots(Stkframe *frame, void*)
Func *f;
BitVector *args, *locals;
uintptr size;
bool afterprologue;
f = frame->fn;
// Scan local variables if stack frame has been allocated.
// Use pointer information if known.
afterprologue = (frame->varp > (byte*)frame->sp);
if(afterprologue) {
if(frame->varp > (byte*)frame->sp) {
locals = runtime·funcdata(f, FUNCDATA_GCLocals);
if(locals == nil) {
// No locals information, scan everything.
......@@ -1482,7 +1450,7 @@ addframeroots(Stkframe *frame, void*)
// Locals bitmap information, scan just the
// pointers in locals.
size = (locals->n*PtrSize) / BitsPerPointer;
scanbitvector(frame->varp - size, locals, false);
scanbitvector(frame->varp - size, locals);
}
}
......@@ -1490,7 +1458,7 @@ addframeroots(Stkframe *frame, void*)
// Use pointer information if known.
args = runtime·funcdata(f, FUNCDATA_GCArgs);
if(args != nil && args->n > 0)
scanbitvector(frame->argp, args, !afterprologue);
scanbitvector(frame->argp, args);
else
addroot((Obj){frame->argp, frame->arglen, 0});
}
......
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