]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1.11] runtime: skip stack barrier copy when there are no pointers
authorInada Naoki <songofacandy@gmail.com>
Wed, 26 Dec 2018 15:47:20 +0000 (00:47 +0900)
committerKatie Hockman <katie@golang.org>
Fri, 4 Jan 2019 20:47:36 +0000 (20:47 +0000)
After CL 31455, "go fun(n)" may put "n" to write barrier buffer
when there are no pointers in fun's arguments.

Updates #29565

Change-Id: Icfa42b8759ce8ad9267dcb3859c626feb6fda381
Reviewed-on: https://go-review.googlesource.com/c/155779
Reviewed-by: Keith Randall <khr@golang.org>
(cherry picked from commit 5372257e600989ab4cf742b35e3fa649cad3f45c)
Reviewed-on: https://go-review.googlesource.com/c/156357
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/runtime/proc.go

index e8495d1a109c920173fb9714b50fe8acc4f61746..e309c505b4a3ce6fd867f831881374542357daa4 100644 (file)
@@ -3371,9 +3371,11 @@ func newproc1(fn *funcval, argp *uint8, narg int32, callergp *g, callerpc uintpt
                if writeBarrier.needed && !_g_.m.curg.gcscandone {
                        f := findfunc(fn.fn)
                        stkmap := (*stackmap)(funcdata(f, _FUNCDATA_ArgsPointerMaps))
-                       // We're in the prologue, so it's always stack map index 0.
-                       bv := stackmapdata(stkmap, 0)
-                       bulkBarrierBitmap(spArg, spArg, uintptr(narg), 0, bv.bytedata)
+                       if stkmap.nbit > 0 {
+                               // We're in the prologue, so it's always stack map index 0.
+                               bv := stackmapdata(stkmap, 0)
+                               bulkBarrierBitmap(spArg, spArg, uintptr(narg), 0, bv.bytedata)
+                       }
                }
        }