]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
runtime: enable precise GC checks when using stack maps
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 5 Mar 2019 23:05:38 +0000 (23:05 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 5 Mar 2019 23:05:38 +0000 (23:05 +0000)
    In the runtime there are bad pointer checks that currently don't
    work with the concervative collector. With stack maps, the GC is
    precise and the checks should work. Enable them.

    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/153871

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@269406 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/go/gofrontend/MERGE
libgo/go/runtime/mgcmark.go
libgo/go/runtime/mgcsweep.go
libgo/go/runtime/runtime1.go

index 3315957aea5496f1455d9509e0bc518a8004f4b4..78dd824fc74e536160dbcf0d514a66432afac8c1 100644 (file)
@@ -1,4 +1,4 @@
-14e48e756af205a68374c872f3bd03d62ccd70bb
+3f8ddaa1d773309b6a4b8e4640f8b9675d9764c6
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index 9da881ed2ab85bc09f23640bd24e3b6051a86bd0..dc5e797739ed6ce19ea701e926169dfc689df127 100644 (file)
@@ -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)
        }
 }
 
index fb5ee6ad46d788c036458bf5a86d934f6f57b604..bc53de44e666a0b2488fdaade4b11d11afbfcccd 100644 (file)
@@ -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)
index 66091ff65808c14960f668c2948f24a77e2ac7b4..e2567b35a3f68b48d24226ac4ff5cf5321d440ad 100644 (file)
@@ -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 := ""