From 5372257e600989ab4cf742b35e3fa649cad3f45c Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Thu, 27 Dec 2018 00:47:20 +0900 Subject: [PATCH] runtime: skip stack barrier copy when there are no pointers 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 --- src/runtime/proc.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/runtime/proc.go b/src/runtime/proc.go index bdf73e0412..f2e7f707ed 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -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) + } } }