aboutsummaryrefslogtreecommitdiff
path: root/libgo/runtime/mgc0.c
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/mgc0.c
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/mgc0.c')
-rw-r--r--libgo/runtime/mgc0.c46
1 files changed, 37 insertions, 9 deletions
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 *)