aboutsummaryrefslogtreecommitdiff
path: root/libgo/runtime
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2012-12-12 23:13:29 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2012-12-12 23:13:29 +0000
commita42a906c420d7bb196cb8541e0ab65264a0b04b0 (patch)
tree8c441679e35147b1e9bec048f733fc394fb0c161 /libgo/runtime
parentbc77608b97abcc4bb3171f08a71e34ae342e9f8d (diff)
downloadgcc-a42a906c420d7bb196cb8541e0ab65264a0b04b0.zip
gcc-a42a906c420d7bb196cb8541e0ab65264a0b04b0.tar.gz
gcc-a42a906c420d7bb196cb8541e0ab65264a0b04b0.tar.bz2
libgo: Update to current master library sources.
From-SVN: r194460
Diffstat (limited to 'libgo/runtime')
-rw-r--r--libgo/runtime/chan.c4
-rw-r--r--libgo/runtime/mgc0.c46
-rw-r--r--libgo/runtime/race.h4
3 files changed, 41 insertions, 13 deletions
diff --git a/libgo/runtime/chan.c b/libgo/runtime/chan.c
index de25e9f..ceee42c 100644
--- a/libgo/runtime/chan.c
+++ b/libgo/runtime/chan.c
@@ -197,7 +197,7 @@ runtime_chansend(ChanType *t, Hchan *c, byte *ep, bool *pres, void *pc)
runtime_lock(c);
// TODO(dvyukov): add similar instrumentation to select.
if(raceenabled)
- runtime_racereadpc(c, pc);
+ runtime_racereadpc(c, pc, runtime_chansend);
if(c->closed)
goto closed;
@@ -1271,7 +1271,7 @@ runtime_closechan(Hchan *c)
}
if(raceenabled) {
- runtime_racewritepc(c, runtime_getcallerpc(&c));
+ runtime_racewritepc(c, runtime_getcallerpc(&c), runtime_closechan);
runtime_racerelease(c);
}
diff --git a/libgo/runtime/mgc0.c b/libgo/runtime/mgc0.c
index 5ea456f..45f8a56 100644
--- a/libgo/runtime/mgc0.c
+++ b/libgo/runtime/mgc0.c
@@ -949,6 +949,7 @@ runtime_memorydump(void)
dumpspan(spanidx);
}
}
+
void
runtime_gchelper(void)
{
@@ -1025,16 +1026,21 @@ cachestats(GCStats *stats)
mstats.stacks_sys = stacks_sys;
}
+// Structure of arguments passed to function gc().
+// This allows the arguments to be passed via reflect_call.
+struct gc_args
+{
+ int32 force;
+};
+
+static void gc(struct gc_args *args);
+
void
runtime_gc(int32 force)
{
M *m;
- int64 t0, t1, t2, t3;
- uint64 heap0, heap1, obj0, obj1;
const byte *p;
- GCStats stats;
- M *m1;
- uint32 i;
+ struct gc_args a, *ap;
// The atomic operations are not atomic if the uint64s
// are not aligned on uint64 boundaries. This has been
@@ -1074,12 +1080,37 @@ runtime_gc(int32 force)
if(gcpercent < 0)
return;
+ // Run gc on a bigger stack to eliminate
+ // a potentially large number of calls to runtime_morestack.
+ // But not when using gccgo.
+ a.force = force;
+ ap = &a;
+ gc(ap);
+
+ if(gctrace > 1 && !force) {
+ a.force = 1;
+ gc(&a);
+ }
+}
+
+static void
+gc(struct gc_args *args)
+{
+ M *m;
+ int64 t0, t1, t2, t3;
+ uint64 heap0, heap1, obj0, obj1;
+ GCStats stats;
+ M *m1;
+ uint32 i;
+
runtime_semacquire(&runtime_worldsema);
- if(!force && mstats.heap_alloc < mstats.next_gc) {
+ if(!args->force && mstats.heap_alloc < mstats.next_gc) {
runtime_semrelease(&runtime_worldsema);
return;
}
+ m = runtime_m();
+
t0 = runtime_nanotime();
m->gcing = 1;
@@ -1181,9 +1212,6 @@ runtime_gc(int32 force)
// give the queued finalizers, if any, a chance to run
if(finq != nil)
runtime_gosched();
-
- if(gctrace > 1 && !force)
- runtime_gc(1);
}
void runtime_ReadMemStats(MStats *)
diff --git a/libgo/runtime/race.h b/libgo/runtime/race.h
index 2d8d095..9f3b3ec 100644
--- a/libgo/runtime/race.h
+++ b/libgo/runtime/race.h
@@ -20,8 +20,8 @@ void runtime_racemalloc(void *p, uintptr sz, void *pc);
void runtime_racefree(void *p);
void runtime_racegostart(int32 goid, void *pc);
void runtime_racegoend(int32 goid);
-void runtime_racewritepc(void *addr, void *pc);
-void runtime_racereadpc(void *addr, void *pc);
+void runtime_racewritepc(void *addr, void *callpc, void *pc);
+void runtime_racereadpc(void *addr, void *callpc, void *pc);
void runtime_racefingo(void);
void runtime_raceacquire(void *addr);
void runtime_raceacquireg(G *gp, void *addr);