mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00: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:
parent
c274a7c03b
commit
89b141c06e
1 changed files with 33 additions and 15 deletions
|
|
@ -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 {
|
func wbcall(pos src.XPos, b *Block, fn, typ *obj.LSym, ptr, val, mem, sp, sb *Value) *Value {
|
||||||
config := b.Func.Config
|
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
|
// put arguments on stack
|
||||||
off := config.ctxt.FixedFrameSize()
|
off := config.ctxt.FixedFrameSize()
|
||||||
|
|
||||||
var argTypes []*types.Type
|
var argTypes []*types.Type
|
||||||
if typ != nil { // for typedmemmove
|
if typ != nil { // for typedmemmove
|
||||||
taddr := b.NewValue1A(pos, OpAddr, b.Func.Config.Types.Uintptr, typ, sb)
|
taddr := b.NewValue1A(pos, OpAddr, b.Func.Config.Types.Uintptr, typ, sb)
|
||||||
|
argTypes = append(argTypes, b.Func.Config.Types.Uintptr)
|
||||||
|
if inRegs {
|
||||||
|
wbargs = append(wbargs, taddr)
|
||||||
|
} else {
|
||||||
off = round(off, taddr.Type.Alignment())
|
off = round(off, taddr.Type.Alignment())
|
||||||
arg := b.NewValue1I(pos, OpOffPtr, taddr.Type.PtrTo(), off, sp)
|
arg := b.NewValue1I(pos, OpOffPtr, taddr.Type.PtrTo(), off, sp)
|
||||||
mem = b.NewValue3A(pos, OpStore, types.TypeMem, ptr.Type, arg, taddr, mem)
|
mem = b.NewValue3A(pos, OpStore, types.TypeMem, ptr.Type, arg, taddr, mem)
|
||||||
argTypes = append(argTypes, b.Func.Config.Types.Uintptr)
|
|
||||||
off += taddr.Type.Size()
|
off += taddr.Type.Size()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
argTypes = append(argTypes, ptr.Type)
|
||||||
|
if inRegs {
|
||||||
|
wbargs = append(wbargs, ptr)
|
||||||
|
} else {
|
||||||
off = round(off, ptr.Type.Alignment())
|
off = round(off, ptr.Type.Alignment())
|
||||||
arg := b.NewValue1I(pos, OpOffPtr, ptr.Type.PtrTo(), off, sp)
|
arg := b.NewValue1I(pos, OpOffPtr, ptr.Type.PtrTo(), off, sp)
|
||||||
mem = b.NewValue3A(pos, OpStore, types.TypeMem, ptr.Type, arg, ptr, mem)
|
mem = b.NewValue3A(pos, OpStore, types.TypeMem, ptr.Type, arg, ptr, mem)
|
||||||
argTypes = append(argTypes, ptr.Type)
|
|
||||||
off += ptr.Type.Size()
|
off += ptr.Type.Size()
|
||||||
|
}
|
||||||
|
|
||||||
if val != nil {
|
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)
|
argTypes = append(argTypes, val.Type)
|
||||||
|
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 += val.Type.Size()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
off = round(off, config.PtrSize)
|
off = round(off, config.PtrSize)
|
||||||
|
wbargs = append(wbargs, mem)
|
||||||
|
|
||||||
// issue call
|
// issue call
|
||||||
mem = b.NewValue1A(pos, OpStaticCall, types.TypeResultMem, StaticAuxCall(fn, b.Func.ABIDefault.ABIAnalyzeTypes(nil, argTypes, nil)), mem)
|
call := b.NewValue0A(pos, OpStaticCall, types.TypeResultMem, StaticAuxCall(fn, b.Func.ABIDefault.ABIAnalyzeTypes(nil, argTypes, nil)))
|
||||||
mem.AuxInt = off - config.ctxt.FixedFrameSize()
|
call.AddArgs(wbargs...)
|
||||||
return b.NewValue1I(pos, OpSelectN, types.TypeMem, 0, mem)
|
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
|
// round to a multiple of r, r is a power of 2
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue