Commit c80f5b9b authored by Carl Shapiro's avatar Carl Shapiro

runtime: use a distinct pattern to mark free blocks in need of zeroing

R=golang-dev, dvyukov, khr, cshapiro
CC=golang-dev
https://golang.org/cl/8392043
parent 13d6f8f7
...@@ -160,7 +160,7 @@ runtime·free(void *v) ...@@ -160,7 +160,7 @@ runtime·free(void *v)
if(sizeclass == 0) { if(sizeclass == 0) {
// Large object. // Large object.
size = s->npages<<PageShift; size = s->npages<<PageShift;
*(uintptr*)(s->start<<PageShift) = 1; // mark as "needs to be zeroed" *(uintptr*)(s->start<<PageShift) = (uintptr)0xfeedfeedfeedfeedll; // mark as "needs to be zeroed"
// Must mark v freed before calling unmarkspan and MHeap_Free: // Must mark v freed before calling unmarkspan and MHeap_Free:
// they might coalesce v into other spans and change the bitmap further. // they might coalesce v into other spans and change the bitmap further.
runtime·markfreed(v, size); runtime·markfreed(v, size);
...@@ -170,7 +170,7 @@ runtime·free(void *v) ...@@ -170,7 +170,7 @@ runtime·free(void *v)
// Small object. // Small object.
size = runtime·class_to_size[sizeclass]; size = runtime·class_to_size[sizeclass];
if(size > sizeof(uintptr)) if(size > sizeof(uintptr))
((uintptr*)v)[1] = 1; // mark as "needs to be zeroed" ((uintptr*)v)[1] = (uintptr)0xfeedfeedfeedfeedll; // mark as "needs to be zeroed"
// Must mark v freed before calling MCache_Free: // Must mark v freed before calling MCache_Free:
// it might coalesce v and other blocks into a bigger span // it might coalesce v and other blocks into a bigger span
// and change the bitmap further. // and change the bitmap further.
......
...@@ -1607,7 +1607,7 @@ sweepspan(ParFor *desc, uint32 idx) ...@@ -1607,7 +1607,7 @@ sweepspan(ParFor *desc, uint32 idx)
if(cl == 0) { if(cl == 0) {
// Free large span. // Free large span.
runtime·unmarkspan(p, 1<<PageShift); runtime·unmarkspan(p, 1<<PageShift);
*(uintptr*)p = 1; // needs zeroing *(uintptr*)p = (uintptr)0xdeaddeaddeaddeadll; // needs zeroing
runtime·MHeap_Free(runtime·mheap, s, 1); runtime·MHeap_Free(runtime·mheap, s, 1);
c->local_alloc -= size; c->local_alloc -= size;
c->local_nfree++; c->local_nfree++;
...@@ -1622,7 +1622,7 @@ sweepspan(ParFor *desc, uint32 idx) ...@@ -1622,7 +1622,7 @@ sweepspan(ParFor *desc, uint32 idx)
break; break;
} }
if(size > sizeof(uintptr)) if(size > sizeof(uintptr))
((uintptr*)p)[1] = 1; // mark as "needs to be zeroed" ((uintptr*)p)[1] = (uintptr)0xdeaddeaddeaddeadll; // mark as "needs to be zeroed"
end->next = (MLink*)p; end->next = (MLink*)p;
end = (MLink*)p; end = (MLink*)p;
......
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