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