]> Cypherpunks repositories - gostls13.git/commitdiff
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)
committerKeith Randall <khr@golang.org>
Thu, 3 Jan 2019 18:48:52 +0000 (18:48 +0000)
After CL 31455, "go fun(n)" may put "n" to write barrier buffer
when there are no pointers in fun's arguments.

Fixes #29362

Change-Id: Icfa42b8759ce8ad9267dcb3859c626feb6fda381
Reviewed-on: https://go-review.googlesource.com/c/155779
Reviewed-by: Keith Randall <khr@golang.org>
src/runtime/proc.go

index bdf73e041204ba1341f1a08fc0af7537f354e4e8..f2e7f707ed0cf5d945f4e2fbc2cf7eeb038cf5c0 100644 (file)
@@ -3303,9 +3303,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)
+                       }
                }
        }