#include "gc.h"
#include "../../pkg/runtime/funcdata.h"
+enum { BitsPerPointer = 2 };
+
static void dumpgcargs(Type *fn, Sym *sym);
int
// pointer types
if((offset + t->offset) % ewidth[TIND] != 0)
yyerror("unaligned pointer");
- bvset(bv, (offset + t->offset) / ewidth[TIND]);
+ bvset(bv, ((offset + t->offset) / ewidth[TIND])*BitsPerPointer);
break;
case TSTRUCT:
Bvec *bv;
Type *t;
int32 i;
+ int32 argbytes;
int32 symoffset, argoffset;
if(hasdotdotdot()) {
gextern(sym, nodconst(0), 0, 4); // nptrs=0
symoffset = 4;
} else {
- bv = bvalloc((argsize() + ewidth[TIND] - 1) / ewidth[TIND]);
+ argbytes = (argsize() + ewidth[TIND] - 1);
+ bv = bvalloc((argbytes / ewidth[TIND]) * BitsPerPointer);
argoffset = align(0, fn->link, Aarg0, nil);
if(argoffset > 0) {
// The C calling convention returns structs by
#include "opt.h"
#include "../../pkg/runtime/funcdata.h"
+enum { BitsPerPointer = 2 };
+
static void allocauto(Prog* p);
static void dumpgcargs(Node*, Sym*);
static void dumpgclocals(Node*, Sym*);
case TMAP:
if(*xoffset % widthptr != 0)
fatal("walktype1: invalid alignment, %T", t);
- bvset(bv, *xoffset / widthptr);
+ bvset(bv, (*xoffset / widthptr) * BitsPerPointer);
*xoffset += t->width;
break;
// struct { byte *str; intgo len; }
if(*xoffset % widthptr != 0)
fatal("walktype1: invalid alignment, %T", t);
- bvset(bv, *xoffset / widthptr);
+ bvset(bv, (*xoffset / widthptr) * BitsPerPointer);
*xoffset += t->width;
break;
// struct { Type* type; union { void* ptr, uintptr val } data; }
if(*xoffset % widthptr != 0)
fatal("walktype1: invalid alignment, %T", t);
- bvset(bv, *xoffset / widthptr);
- bvset(bv, (*xoffset + widthptr) / widthptr);
+ bvset(bv, ((*xoffset / widthptr) * BitsPerPointer) + 1);
+ if(isnilinter(t))
+ bvset(bv, ((*xoffset / widthptr) * BitsPerPointer));
+ bvset(bv, ((*xoffset + widthptr) / widthptr) * BitsPerPointer);
*xoffset += t->width;
break;
// struct { byte* array; uintgo len; uintgo cap; }
if(*xoffset % widthptr != 0)
fatal("walktype1: invalid TARRAY alignment, %T", t);
- bvset(bv, *xoffset / widthptr);
+ bvset(bv, (*xoffset / widthptr) * BitsPerPointer);
*xoffset += t->width;
} else if(!haspointers(t->type))
*xoffset += t->width;
thistype = getthisx(fn->type);
inargtype = getinargx(fn->type);
outargtype = getoutargx(fn->type);
- bv = bvalloc(fn->type->argwid / widthptr);
+ bv = bvalloc((fn->type->argwid / widthptr) * BitsPerPointer);
if(thistype != nil)
walktype(thistype, bv);
if(inargtype != nil)
int32 i;
int off;
- bv = bvalloc(stkptrsize / widthptr);
+ bv = bvalloc((stkptrsize / widthptr) * BitsPerPointer);
for(ll = fn->dcl; ll != nil; ll = ll->next) {
node = ll->n;
if(node->class == PAUTO && node->op == ONAME) {
PRECISE = 1,
LOOP = 2,
PC_BITS = PRECISE | LOOP,
+
+ // Pointer map
+ BitsPerPointer = 2,
};
// Bits in per-word bitmap.
i = remptrs;
else
i = 32;
+ i /= BitsPerPointer;
for(; i > 0; i--) {
- if(w & 1)
+ if(w & 3)
addroot((Obj){scanp, PtrSize, 0});
- w >>= 1;
+ w >>= BitsPerPointer;
scanp += PtrSize;
}
}
} else if(locals->n > 0) {
// Locals bitmap information, scan just the
// pointers in locals.
- size = locals->n*PtrSize;
+ size = (locals->n*PtrSize) / BitsPerPointer;
scanbitvector(frame->varp - size, locals);
}
}