Commit 3877f1d9 authored by Dmitriy Vyukov's avatar Dmitriy Vyukov

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
parent 38f6c3f5
...@@ -2614,26 +2614,12 @@ runfinq(void) ...@@ -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
......
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