1
0
mirror of https://github.com/golang/go synced 2024-11-26 05:57:58 -07:00

cmd/compile: emit writebarriers in specified ABI

old code was always ABI0, new code tracks the default
this may cause some write barrier removals to fail to fire

Updates #40724.

Change-Id: I656bdd5511c5bd6ee6e021999e30d842a6b9f0a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/305671
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
David Chase 2021-03-29 18:46:37 -04:00
parent c274a7c03b
commit 89b141c06e

View File

@ -483,38 +483,56 @@ func (f *Func) computeZeroMap() map[ID]ZeroRegion {
func wbcall(pos src.XPos, b *Block, fn, typ *obj.LSym, ptr, val, mem, sp, sb *Value) *Value {
config := b.Func.Config
var wbargs []*Value
// TODO (register args) this is a bit of a hack.
inRegs := b.Func.ABIDefault == b.Func.ABI1 && len(config.intParamRegs) >= 3
// put arguments on stack
off := config.ctxt.FixedFrameSize()
var argTypes []*types.Type
if typ != nil { // for typedmemmove
taddr := b.NewValue1A(pos, OpAddr, b.Func.Config.Types.Uintptr, typ, sb)
off = round(off, taddr.Type.Alignment())
arg := b.NewValue1I(pos, OpOffPtr, taddr.Type.PtrTo(), off, sp)
mem = b.NewValue3A(pos, OpStore, types.TypeMem, ptr.Type, arg, taddr, mem)
argTypes = append(argTypes, b.Func.Config.Types.Uintptr)
off += taddr.Type.Size()
if inRegs {
wbargs = append(wbargs, taddr)
} else {
off = round(off, taddr.Type.Alignment())
arg := b.NewValue1I(pos, OpOffPtr, taddr.Type.PtrTo(), off, sp)
mem = b.NewValue3A(pos, OpStore, types.TypeMem, ptr.Type, arg, taddr, mem)
off += taddr.Type.Size()
}
}
off = round(off, ptr.Type.Alignment())
arg := b.NewValue1I(pos, OpOffPtr, ptr.Type.PtrTo(), off, sp)
mem = b.NewValue3A(pos, OpStore, types.TypeMem, ptr.Type, arg, ptr, mem)
argTypes = append(argTypes, ptr.Type)
off += ptr.Type.Size()
if inRegs {
wbargs = append(wbargs, ptr)
} else {
off = round(off, ptr.Type.Alignment())
arg := b.NewValue1I(pos, OpOffPtr, ptr.Type.PtrTo(), off, sp)
mem = b.NewValue3A(pos, OpStore, types.TypeMem, ptr.Type, arg, ptr, mem)
off += ptr.Type.Size()
}
if val != nil {
off = round(off, val.Type.Alignment())
arg = b.NewValue1I(pos, OpOffPtr, val.Type.PtrTo(), off, sp)
mem = b.NewValue3A(pos, OpStore, types.TypeMem, val.Type, arg, val, mem)
argTypes = append(argTypes, val.Type)
off += val.Type.Size()
if inRegs {
wbargs = append(wbargs, val)
} else {
off = round(off, val.Type.Alignment())
arg := b.NewValue1I(pos, OpOffPtr, val.Type.PtrTo(), off, sp)
mem = b.NewValue3A(pos, OpStore, types.TypeMem, val.Type, arg, val, mem)
off += val.Type.Size()
}
}
off = round(off, config.PtrSize)
wbargs = append(wbargs, mem)
// issue call
mem = b.NewValue1A(pos, OpStaticCall, types.TypeResultMem, StaticAuxCall(fn, b.Func.ABIDefault.ABIAnalyzeTypes(nil, argTypes, nil)), mem)
mem.AuxInt = off - config.ctxt.FixedFrameSize()
return b.NewValue1I(pos, OpSelectN, types.TypeMem, 0, mem)
call := b.NewValue0A(pos, OpStaticCall, types.TypeResultMem, StaticAuxCall(fn, b.Func.ABIDefault.ABIAnalyzeTypes(nil, argTypes, nil)))
call.AddArgs(wbargs...)
call.AuxInt = off - config.ctxt.FixedFrameSize()
return b.NewValue1I(pos, OpSelectN, types.TypeMem, 0, call)
}
// round to a multiple of r, r is a power of 2