aboutsummaryrefslogtreecommitdiff
path: root/libgo/runtime/mheap.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2012-11-21 07:03:38 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2012-11-21 07:03:38 +0000
commitfabcaa8df3d6eb852b87821ef090d31d222870b7 (patch)
tree72455aea0286937aa08cc141e5efc800e4626577 /libgo/runtime/mheap.c
parenta51fb17f48428e7cfc96a72a9f9f87901363bb6b (diff)
downloadgcc-fabcaa8df3d6eb852b87821ef090d31d222870b7.zip
gcc-fabcaa8df3d6eb852b87821ef090d31d222870b7.tar.gz
gcc-fabcaa8df3d6eb852b87821ef090d31d222870b7.tar.bz2
libgo: Update to current version of master library.
From-SVN: r193688
Diffstat (limited to 'libgo/runtime/mheap.c')
-rw-r--r--libgo/runtime/mheap.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/libgo/runtime/mheap.c b/libgo/runtime/mheap.c
index 61ef4dd..7be135b 100644
--- a/libgo/runtime/mheap.c
+++ b/libgo/runtime/mheap.c
@@ -343,6 +343,15 @@ MHeap_FreeLocked(MHeap *h, MSpan *s)
runtime_MSpanList_Insert(&h->large, s);
}
+static void
+forcegchelper(void *vnote)
+{
+ Note *note = (Note*)vnote;
+
+ runtime_gc(1);
+ runtime_notewakeup(note);
+}
+
// Release (part of) unused memory to OS.
// Goroutine created at startup.
// Loop forever.
@@ -356,7 +365,7 @@ runtime_MHeap_Scavenger(void* dummy)
uintptr released, sumreleased;
const byte *env;
bool trace;
- Note note;
+ Note note, *notep;
USED(dummy);
@@ -387,7 +396,15 @@ runtime_MHeap_Scavenger(void* dummy)
now = runtime_nanotime();
if(now - mstats.last_gc > forcegc) {
runtime_unlock(h);
- runtime_gc(1);
+ // The scavenger can not block other goroutines,
+ // otherwise deadlock detector can fire spuriously.
+ // GC blocks other goroutines via the runtime_worldsema.
+ runtime_noteclear(&note);
+ notep = &note;
+ __go_go(forcegchelper, (void*)&notep);
+ runtime_entersyscall();
+ runtime_notesleep(&note);
+ runtime_exitsyscall();
runtime_lock(h);
now = runtime_nanotime();
if (trace)