aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/runtime
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2019-03-18 21:23:09 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2019-03-18 21:23:09 +0000
commit10f47d3d1dc2e1267a32fa6459655b4645a9adad (patch)
tree97d68e0e70fb780b04f3171a0f53102a39c23f41 /libgo/go/runtime
parentf8c264049036ace8b02a73fe76b4470b8e0df0c0 (diff)
parenta8b58d84bf4fd9c925a835ba39c1c552383bc61b (diff)
downloadgcc-10f47d3d1dc2e1267a32fa6459655b4645a9adad.zip
gcc-10f47d3d1dc2e1267a32fa6459655b4645a9adad.tar.gz
gcc-10f47d3d1dc2e1267a32fa6459655b4645a9adad.tar.bz2
Merge from trunk revision 269780.
From-SVN: r269782
Diffstat (limited to 'libgo/go/runtime')
-rw-r--r--libgo/go/runtime/mgcmark.go4
-rw-r--r--libgo/go/runtime/mgcsweep.go6
-rw-r--r--libgo/go/runtime/runtime1.go4
-rw-r--r--libgo/go/runtime/testdata/testprog/gc.go23
4 files changed, 32 insertions, 5 deletions
diff --git a/libgo/go/runtime/mgcmark.go b/libgo/go/runtime/mgcmark.go
index 9da881e..dc5e797 100644
--- a/libgo/go/runtime/mgcmark.go
+++ b/libgo/go/runtime/mgcmark.go
@@ -1106,9 +1106,9 @@ func scanstackblockwithmap(pc, b0, n0 uintptr, ptrmask *uint8, gcw *gcWork) {
// Preemption must be disabled.
//go:nowritebarrier
func shade(b uintptr) {
- if obj, span, objIndex := findObject(b, 0, 0, true); obj != 0 {
+ if obj, span, objIndex := findObject(b, 0, 0, !usestackmaps); obj != 0 {
gcw := &getg().m.p.ptr().gcw
- greyobject(obj, 0, 0, span, gcw, objIndex, true)
+ greyobject(obj, 0, 0, span, gcw, objIndex, !usestackmaps)
}
}
diff --git a/libgo/go/runtime/mgcsweep.go b/libgo/go/runtime/mgcsweep.go
index fb5ee6a..bc53de4 100644
--- a/libgo/go/runtime/mgcsweep.go
+++ b/libgo/go/runtime/mgcsweep.go
@@ -342,8 +342,10 @@ func (s *mspan) sweep(preserve bool) bool {
// it is not otherwise a problem. So we disable the test for gccgo.
nfreedSigned := int(nfreed)
if nalloc > s.allocCount {
- // print("runtime: nelems=", s.nelems, " nalloc=", nalloc, " previous allocCount=", s.allocCount, " nfreed=", nfreed, "\n")
- // throw("sweep increased allocation count")
+ if usestackmaps {
+ print("runtime: nelems=", s.nelems, " nalloc=", nalloc, " previous allocCount=", s.allocCount, " nfreed=", nfreed, "\n")
+ throw("sweep increased allocation count")
+ }
// For gccgo, adjust the freed count as a signed number.
nfreedSigned = int(s.allocCount) - int(nalloc)
diff --git a/libgo/go/runtime/runtime1.go b/libgo/go/runtime/runtime1.go
index 66091ff..e2567b3 100644
--- a/libgo/go/runtime/runtime1.go
+++ b/libgo/go/runtime/runtime1.go
@@ -362,7 +362,9 @@ func parsedebugvars() {
// At that point, if debug.invalidptr is set, we crash.
// This is not a problem, assuming that M1 really is dead and
// the pointer we discovered to it will not be used.
- // debug.invalidptr = 1
+ if usestackmaps {
+ debug.invalidptr = 1
+ }
for p := gogetenv("GODEBUG"); p != ""; {
field := ""
diff --git a/libgo/go/runtime/testdata/testprog/gc.go b/libgo/go/runtime/testdata/testprog/gc.go
index 6b308e0..629cf2f 100644
--- a/libgo/go/runtime/testdata/testprog/gc.go
+++ b/libgo/go/runtime/testdata/testprog/gc.go
@@ -18,6 +18,7 @@ func init() {
register("GCFairness2", GCFairness2)
register("GCSys", GCSys)
register("GCPhys", GCPhys)
+ register("DeferLiveness", DeferLiveness)
}
func GCSys() {
@@ -210,3 +211,25 @@ func GCPhys() {
fmt.Println("OK")
runtime.KeepAlive(saved)
}
+
+// Test that defer closure is correctly scanned when the stack is scanned.
+func DeferLiveness() {
+ var x [10]int
+ escape(&x)
+ fn := func() {
+ if x[0] != 42 {
+ panic("FAIL")
+ }
+ }
+ defer fn()
+
+ x[0] = 42
+ runtime.GC()
+ runtime.GC()
+ runtime.GC()
+}
+
+//go:noinline
+func escape(x interface{}) { sink2 = x; sink2 = nil }
+
+var sink2 interface{}