summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2016-10-13 15:24:50 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2016-10-13 15:24:50 +0000
commit634150fbd353b4b99a31c94963f1decb51fb8e51 (patch)
treed5aaac15d5bd0d4b125140016f3ea84a714e3713 /gcc
parentff56abd1656bc6c0f4606f203fa06fab74efa1de (diff)
runtime: copy mstats code from Go 1.7 runtime
This replaces mem.go and the C runtime_ReadMemStats function with the Go 1.7 mstats.go. The GCStats code is commented out for now. The corresponding gccgo code is in runtime/mgc0.c. The variables memstats and worldsema are shared between the Go code and the C code, but are not exported. To make this work, add temporary accessor functions acquireWorldsema, releaseWorldsema, getMstats (the latter known as mstats in the C code). Check the preemptoff field of m when allocating and when considering whether to start a GC. This works with the new stopTheWorld and startTheWorld functions in Go, which are essentially the Go 1.7 versions. Change the compiler to stack allocate closures when compiling the runtime package. Within the runtime packages closures do not escape. This is similar to what the gc compiler does, except that the gc compiler, when compiling the runtime package, gives an error if escape analysis shows that a closure does escape. I added this here because the Go version of ReadMemStats calls systemstack with a closure, and having that allocate memory was causing some tests that measure memory allocations to fail. Reviewed-on: https://go-review.googlesource.com/30972 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@241124 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--gcc/go/gofrontend/parse.cc15
2 files changed, 16 insertions, 1 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 08a86e9201c4..0a116a835e94 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-6c9070324d5b7c8483bc7c17b0a8faaa1fb1ae30
+681580a3afc687ba3ff9ef240c67e8630e4306e6
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/parse.cc b/gcc/go/gofrontend/parse.cc
index 81525a741d7c..b7411d14ffa4 100644
--- a/gcc/go/gofrontend/parse.cc
+++ b/gcc/go/gofrontend/parse.cc
@@ -3026,6 +3026,21 @@ Parse::create_closure(Named_object* function, Enclosing_vars* enclosing_vars,
Struct_type* st = closure_var->var_value()->type()->deref()->struct_type();
Expression* cv = Expression::make_struct_composite_literal(st, initializer,
location);
+
+ // When compiling the runtime, closures do not escape. When escape
+ // analysis becomes the default, and applies to closures, this
+ // should be changed to make it an error if a closure escapes.
+ if (this->gogo_->compiling_runtime()
+ && this->gogo_->package_name() == "runtime")
+ {
+ Temporary_statement* ctemp = Statement::make_temporary(st, cv, location);
+ this->gogo_->add_statement(ctemp);
+ Expression* ref = Expression::make_temporary_reference(ctemp, location);
+ Expression* addr = Expression::make_unary(OPERATOR_AND, ref, location);
+ addr->unary_expression()->set_does_not_escape();
+ return addr;
+ }
+
return Expression::make_heap_expression(cv, location);
}