Commit 9903d687 authored by Dmitriy Vyukov's avatar Dmitriy Vyukov

runtime: minor refactoring in preparation for parallel GC

factor sweepspan() out of sweep(), no logical changes

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5991047
parent d839a809
......@@ -719,22 +719,17 @@ handlespecial(byte *p, uintptr size)
return true;
}
static void sweepspan(MSpan *s);
// Sweep frees or collects finalizers for blocks not marked in the mark phase.
// It clears the mark bits in preparation for the next GC round.
static void
sweep(void)
{
MSpan *s;
int32 cl, n, npages;
uintptr size;
byte *p;
MCache *c;
byte *arena_start;
int64 now;
arena_start = runtime·mheap.arena_start;
now = runtime·nanotime();
for(;;) {
s = work.spans;
if(s == nil)
......@@ -750,6 +745,20 @@ sweep(void)
if(s->state != MSpanInUse)
continue;
sweepspan(s);
}
}
static void
sweepspan(MSpan *s)
{
int32 cl, n, npages;
uintptr size;
byte *p;
MCache *c;
byte *arena_start;
arena_start = runtime·mheap.arena_start;
p = (byte*)(s->start << PageShift);
cl = s->sizeclass;
if(cl == 0) {
......@@ -813,7 +822,6 @@ sweep(void)
c->local_alloc -= size;
c->local_nfree++;
}
}
}
void
......
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