]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: allow write barriers in startpanic_m
authorAustin Clements <austin@google.com>
Sun, 22 Oct 2017 22:10:08 +0000 (18:10 -0400)
committerAustin Clements <austin@google.com>
Sun, 29 Oct 2017 17:56:14 +0000 (17:56 +0000)
We're about to start tracking nowritebarrierrec through systemstack
calls, which will reveal write barriers in startpanic_m prohibited by
various callers.

We actually can allow write barriers here because the write barrier is
a no-op when we're panicking. Let the compiler know.

Updates #22384.
For #22460.

Change-Id: Ifb3a38d3dd9a4125c278c3680f8648f987a5b0b8
Reviewed-on: https://go-review.googlesource.com/72770
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
src/runtime/mbarrier.go
src/runtime/panic.go

index acc4d14e80cd0c275c4f21c18f929ddd6ffa4cab..fbead6d3785f1eddacef9b7040dc86d1b1bae056 100644 (file)
@@ -182,6 +182,8 @@ func gcmarkwb_m(slot *uintptr, ptr uintptr) {
 func writebarrierptr_prewrite1(dst *uintptr, src uintptr) {
        mp := acquirem()
        if mp.inwb || mp.dying > 0 {
+               // We explicitly allow write barriers in startpanic_m,
+               // since we're going down anyway. Ignore them here.
                releasem(mp)
                return
        }
index 90a1c0bdd104a50ed6c085b65a2d7a82a07451d4..11cb05e97698a1abff5ef240704d1429fb809aa9 100644 (file)
@@ -654,6 +654,12 @@ func recovery(gp *g) {
        gogo(&gp.sched)
 }
 
+// startpanic_m implements unrecoverable panic.
+//
+// It can have write barriers because the write barrier explicitly
+// ignores writes once dying > 0.
+//
+//go:yeswritebarrierrec
 func startpanic_m() {
        _g_ := getg()
        if mheap_.cachealloc.size == 0 { // very early