Commit 2b7505e2 authored by Shenghou Ma's avatar Shenghou Ma Committed by Minux Ma

cmd/internal/gc: fix write barrier fast path on RISC architectures

They have to read the boolean into a register first and then do
the comparison.

Fixes #10598.

Change-Id: I2b808837a8c6393e1e0778296b6592aaab2b04bf
Signed-off-by: default avatarShenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/9453Reviewed-by: default avatarDave Cheney <dave@cheney.net>
parent e7dd2889
...@@ -803,7 +803,19 @@ func cgen_wbptr(n, res *Node) { ...@@ -803,7 +803,19 @@ func cgen_wbptr(n, res *Node) {
Cgenr(n, &src, nil) Cgenr(n, &src, nil)
} }
Thearch.Gins(Thearch.Optoas(OCMP, Types[TUINT8]), syslook("writeBarrierEnabled", 0), Nodintconst(0)) wbEnabled := syslook("writeBarrierEnabled", 0)
switch Ctxt.Arch.Thechar {
default:
Fatal("cgen_wbptr: unknown architecture")
case '5', '7', '9':
var tmp Node
Regalloc(&tmp, Types[TUINT8], nil)
Thearch.Gmove(wbEnabled, &tmp)
Thearch.Gins(Thearch.Optoas(OCMP, Types[TUINT8]), &tmp, Nodintconst(0))
Regfree(&tmp)
case '6', '8':
Thearch.Gins(Thearch.Optoas(OCMP, Types[TUINT8]), wbEnabled, Nodintconst(0))
}
pbr := Gbranch(Thearch.Optoas(ONE, Types[TUINT8]), nil, -1) pbr := Gbranch(Thearch.Optoas(ONE, Types[TUINT8]), nil, -1)
Thearch.Gins(Thearch.Optoas(OAS, Types[Tptr]), &src, &dst) Thearch.Gins(Thearch.Optoas(OAS, Types[Tptr]), &src, &dst)
pjmp := Gbranch(obj.AJMP, nil, 0) pjmp := Gbranch(obj.AJMP, nil, 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment