]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.8] cmd/compile: do not use "oaslit" for global
authorCherry Zhang <cherryyz@google.com>
Mon, 6 Feb 2017 19:24:16 +0000 (14:24 -0500)
committerCherry Zhang <cherryyz@google.com>
Tue, 7 Feb 2017 17:39:16 +0000 (17:39 +0000)
commit1edfd647618afadfeda029372ce169f42821e156
treec19c80523fa5b829b20009d89d2704c3ee74b1b2
parent6eb0f5440e7034235544001faa675a0945a1ba7b
[release-branch.go1.8] cmd/compile: do not use "oaslit" for global

The compiler did not emit write barrier for assigning global with
struct literal, like global = T{} where T contains pointer.

The relevant code path is:
walkexpr OAS var_ OSTRUCTLIT
    oaslit
        anylit OSTRUCTLIT
            walkexpr OAS var_ nil
            return without adding write barrier
    return true
break (without adding write barrier)

This CL makes oaslit not apply to globals. See also CL
https://go-review.googlesource.com/c/36355/ for an alternative
fix.

The downside of this is that it generates static data for zeroing
struct now. Also this only covers global. If there is any lurking
bug with implicit zeroing other than globals, this doesn't fix.

Fixes #18956.

Change-Id: Ibcd27e4fae3aa38390ffa94a32a9dd7a802e4b37
Reviewed-on: https://go-review.googlesource.com/36410
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
(cherry picked from commit 160914e33ca6521d74297291d801062cc44d794d)
Reviewed-on: https://go-review.googlesource.com/36531
src/cmd/compile/internal/gc/sinit.go
test/writebarrier.go