mirror of
https://github.com/golang/go
synced 2024-11-23 04:50:06 -07:00
runtime: remove atomic CAS loop from marknogc
Spans are now private to threads, and the loop is removed from all other functions. Remove it from marknogc for consistency. LGTM=khr, rsc R=golang-codereviews, bradfitz, khr CC=golang-codereviews, khr, rsc https://golang.org/cl/72520043
This commit is contained in:
parent
38f6c3f59d
commit
3877f1d9c8
@ -2614,26 +2614,12 @@ runfinq(void)
|
|||||||
void
|
void
|
||||||
runtime·marknogc(void *v)
|
runtime·marknogc(void *v)
|
||||||
{
|
{
|
||||||
uintptr *b, obits, bits, off, shift;
|
uintptr *b, off, shift;
|
||||||
|
|
||||||
off = (uintptr*)v - (uintptr*)runtime·mheap.arena_start; // word offset
|
off = (uintptr*)v - (uintptr*)runtime·mheap.arena_start; // word offset
|
||||||
b = (uintptr*)runtime·mheap.arena_start - off/wordsPerBitmapWord - 1;
|
b = (uintptr*)runtime·mheap.arena_start - off/wordsPerBitmapWord - 1;
|
||||||
shift = off % wordsPerBitmapWord;
|
shift = off % wordsPerBitmapWord;
|
||||||
|
*b = (*b & ~(bitAllocated<<shift)) | bitBlockBoundary<<shift;
|
||||||
for(;;) {
|
|
||||||
obits = *b;
|
|
||||||
if((obits>>shift & bitMask) != bitAllocated)
|
|
||||||
runtime·throw("bad initial state for marknogc");
|
|
||||||
bits = (obits & ~(bitAllocated<<shift)) | bitBlockBoundary<<shift;
|
|
||||||
if(runtime·gomaxprocs == 1) {
|
|
||||||
*b = bits;
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
// more than one goroutine is potentially running: use atomic op
|
|
||||||
if(runtime·casp((void**)b, (void*)obits, (void*)bits))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user